core

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrResponseNotImplemented         = errors.New("response type not implemented")
	ErrInvalidRouteResponseType       = errors.New("invalid route response type")
	ErrInvalidRequestBodyKeysAmount   = errors.New("requestBody function only supports one or zero aguments")
	ErrInvalidRequestBodyArgumentType = errors.New("requestBody argument should be a string")
)

Functions

This section is empty.

Types

type Loader

type Loader interface {
	Load(r *http.Request) ([]RouteDefinition, error)
}

type Result

type Result struct {
	StatusCode int
	Body       *string
	Headers    map[string]string
}

type RouteDefinition

type RouteDefinition struct {
	Path     string
	Method   string
	Response RouteResponse
}

func NewRouteDefinition

func NewRouteDefinition(path, method string, response RouteResponse) *RouteDefinition

type RouteResponse

type RouteResponse struct {
	Type       RouteResponseType
	StatusCode int
	Body       string
	Headers    map[string]string
	Delay      time.Duration
}

func NewRouteResponse

func NewRouteResponse(t RouteResponseType, statusCode int, body string, headers map[string]string, delay time.Duration) *RouteResponse

func (RouteResponse) BuildResponse

func (rr RouteResponse) BuildResponse(r *http.Request) (Result, error)

type RouteResponseType

type RouteResponseType string
const (
	RESPONSE_TYPE_STATIC  RouteResponseType = "STATIC"
	RESPONSE_TYPE_DYNAMIC RouteResponseType = "DYNAMIC"
)

func NewRouteResponseType

func NewRouteResponseType(t string) (RouteResponseType, error)

func (RouteResponseType) String

func (rr RouteResponseType) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL