Documentation ¶
Index ¶
- Constants
- func Respond(req web.RequestInterface, status *web.ResponseStatus) error
- type Array
- type Config
- func (config *Config) BuildOpenAPISpec(req web.RequestInterface) *openapi.APISpec
- func (config *Config) ForceTLS()
- func (config *Config) GetRootFunction(functionKey string) func(req web.RequestInterface) *web.ResponseStatus
- func (config *Config) NoCache()
- func (config *Config) SetDelims(l, r string)
- func (config *Config) SetHeaders(h Headers)
- func (config *Config) SetRootRegistry(reg Registry)
- func (config *Config) SubTree(subdomain string) *Node
- type Handler
- func (handler *Handler) ApiUrl() string
- func (handler *Handler) Body(objects ...*Payload) *Handler
- func (handler *Handler) BodyIsArray() *Handler
- func (handler *Handler) BodyIsObject() *Handler
- func (handler *Handler) Describe(descr string) *Handler
- func (handler *Handler) DetectContentType(req web.RequestInterface, filePath string) *web.ResponseStatus
- func (handler *Handler) OptionalBody(obj *Optional) *Handler
- func (handler *Handler) Patch(objects ...*Patch) *Handler
- func (handler *Handler) ReadPayload(req web.RequestInterface) *web.ResponseStatus
- func (handler *Handler) Response(schema ...interface{}) *Handler
- func (handler *Handler) Spec(req web.RequestInterface) *HandlerSpec
- func (handler *Handler) UseFunction(f interface{})
- type HandlerArray
- type HandlerSpec
- type Headers
- type Middleware
- type MiddlewareFunction
- type Module
- type ModuleFunction
- type ModuleRegistry
- type Node
- func (node *Node) Add(path string, pathKeys ...string) *Node
- func (node *Node) AuthBearer() *Node
- func (node *Node) DELETE(functions ...interface{}) *Handler
- func (node *Node) File(path string) *Node
- func (node *Node) Folder(directoryPath string, filters ...string) *Node
- func (node *Node) FullPath() string
- func (node *Node) GET(functions ...interface{}) *Handler
- func (node *Node) HEAD(functions ...interface{}) *Handler
- func (node *Node) Init(function ModuleFunction, arg interface{}) *Node
- func (node *Node) MainHandler(req web.RequestInterface, fullPath string) (status *web.ResponseStatus)
- func (node *Node) Mid(function MiddlewareFunction, arg interface{}) *Node
- func (node *Node) Mod(function ModuleFunction, arg interface{}) *Node
- func (node *Node) Next(req web.RequestInterface, pathSegment string) (*Node, *web.ResponseStatus)
- func (node *Node) PATCH(functions ...interface{}) *Handler
- func (node *Node) POST(functions ...interface{}) *Handler
- func (node *Node) PUT(functions ...interface{}) *Handler
- func (node *Node) Param(vc *validation.Config, keys ...string) *Node
- func (node *Node) Path() string
- func (node *Node) RequestParams() map[string]interface{}
- func (node *Node) RunModule(req web.RequestInterface) *web.ResponseStatus
- func (node *Node) RunModules(req web.RequestInterface) *web.ResponseStatus
- func (node *Node) StaticFolder(directoryPath string, filters ...string) *Node
- type Object
- type Optional
- type Patch
- type Payload
- type Registry
- type Router
Constants ¶
const (
ROBOTS_TXT = "User-agent: *\nDisallow: /api/"
)
Variables ¶
This section is empty.
Functions ¶
func Respond ¶
func Respond(req web.RequestInterface, status *web.ResponseStatus) error
Types ¶
type Config ¶
type Config struct { Spec *openapi.APISpec Log logging.Logger // ProjectName is for App Engine apps ProjectName string RootRegistry Registry SubdomainTrees map[string]*Node Handlers []*Handler sync.RWMutex // contains filtered or unexported fields }
func (*Config) BuildOpenAPISpec ¶
func (config *Config) BuildOpenAPISpec(req web.RequestInterface) *openapi.APISpec
Builds the handler documentation object.
func (*Config) GetRootFunction ¶
func (config *Config) GetRootFunction(functionKey string) func(req web.RequestInterface) *web.ResponseStatus
Returns the root function if present in the registry
func (*Config) SetHeaders ¶
Sets the http preflight headers to the specified map
func (*Config) SetRootRegistry ¶
Sets the root registry to the specified map
type Handler ¶
type Handler struct { Config *Config Node *Node Method string Description string IsFile bool sync.RWMutex // contains filtered or unexported fields }
func (*Handler) BodyIsArray ¶
Applies model which describes request payload
func (*Handler) BodyIsObject ¶
Applies model which describes request payload
func (*Handler) DetectContentType ¶
func (handler *Handler) DetectContentType(req web.RequestInterface, filePath string) *web.ResponseStatus
func (*Handler) OptionalBody ¶
Applies model which describes request payload
func (*Handler) ReadPayload ¶
func (handler *Handler) ReadPayload(req web.RequestInterface) *web.ResponseStatus
Validates any payload present in the request body, according to the payloadSchema
func (*Handler) Spec ¶
func (handler *Handler) Spec(req web.RequestInterface) *HandlerSpec
func (*Handler) UseFunction ¶
func (handler *Handler) UseFunction(f interface{})
type HandlerArray ¶
type HandlerArray []*HandlerSpec
func (HandlerArray) Len ¶
func (a HandlerArray) Len() int
func (HandlerArray) Less ¶
func (a HandlerArray) Less(x, y int) bool
func (HandlerArray) Swap ¶
func (a HandlerArray) Swap(x, y int)
type HandlerSpec ¶
type HandlerSpec struct { Method string `json:"method"` Endpoint string `json:"endpoint"` MockEndpoint string `json:"mockEndpoint"` MockPayload interface{} `json:"mockPayload,omitempty"` PayloadSchema interface{} `json:"payloadSchema,omitempty"` OptionalPayloadSchema interface{} `json:"optionalPayloadSchema,omitempty"` ResponseSchema interface{} `json:"responseSchema,omitempty"` RouteParams map[string]*validation.Config `json:"routeParams,omitempty"` IsFile bool `json:"isFile"` FilePath string `json:"filePath,omitempty"` Description string `json:"description,omitempty"` }
func (*HandlerSpec) NewMockPath ¶
func (spec *HandlerSpec) NewMockPath(patches ...map[string]interface{})
func (*HandlerSpec) NewMockPayload ¶
func (spec *HandlerSpec) NewMockPayload(patches ...map[string]interface{})
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
func (*Middleware) Run ¶
func (mid *Middleware) Run(req web.RequestInterface) *web.ResponseStatus
type MiddlewareFunction ¶
type MiddlewareFunction func(*Middleware, web.RequestInterface, interface{}) *web.ResponseStatus
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
func (*Module) Run ¶
func (mod *Module) Run(req web.RequestInterface) *web.ResponseStatus
type ModuleFunction ¶
type ModuleFunction func(web.RequestInterface, interface{}) *web.ResponseStatus
type ModuleRegistry ¶
type ModuleRegistry map[string]ModuleFunction
type Node ¶
type Node struct { Config *Config Validation *validation.Config Validations []*validation.Config sync.RWMutex // contains filtered or unexported fields }
func (*Node) Folder ¶
Walks through the specified folder to mirror the file structure for files containing all filters
func (*Node) Init ¶
func (node *Node) Init(function ModuleFunction, arg interface{}) *Node
Adds a module that will be executed at the point it is added to the route
func (*Node) MainHandler ¶
func (node *Node) MainHandler(req web.RequestInterface, fullPath string) (status *web.ResponseStatus)
main handler
func (*Node) Mid ¶
func (node *Node) Mid(function MiddlewareFunction, arg interface{}) *Node
Adds a module that will be executed upon reaching a handler
func (*Node) Mod ¶
func (node *Node) Mod(function ModuleFunction, arg interface{}) *Node
Adds a module that will be executed upon reaching a handler
func (*Node) Next ¶
func (node *Node) Next(req web.RequestInterface, pathSegment string) (*Node, *web.ResponseStatus)
finds next node according to supplied URL path segment
func (*Node) Param ¶
func (node *Node) Param(vc *validation.Config, keys ...string) *Node
Adds a new param-node
func (*Node) RequestParams ¶
returns the base param map including node params
func (*Node) RunModule ¶
func (node *Node) RunModule(req web.RequestInterface) *web.ResponseStatus
execute init function added with .Init(...)
func (*Node) RunModules ¶
func (node *Node) RunModules(req web.RequestInterface) *web.ResponseStatus
execute all module functions added with .Mod(...)
type Optional ¶
type Optional map[string]*validation.Config
type Patch ¶
type Patch map[string]*validation.Config
type Registry ¶
type Registry map[string]func(req web.RequestInterface) *web.ResponseStatus