Documentation ¶
Index ¶
- Variables
- func HandlerFromFn(fptr interface{}, fn RequestHandler, components openapi.Components, ...) (http.HandlerFunc, error)
- func HandlerFromFnDefault(fnPtr interface{}, fn RequestHandler, components openapi.Components) (http.HandlerFunc, error)
- type Hooks
- type Middleware
- type QueryParamError
- type ReflectRouter
- func (r *ReflectRouter) Connect(pattern string, handler interface{}, options []operations.Option, ...)
- func (r *ReflectRouter) Container() *container.Container
- func (r *ReflectRouter) Delete(pattern string, handler interface{}, options []operations.Option, ...)
- func (r *ReflectRouter) Get(pattern string, handler interface{}, options []operations.Option, ...)
- func (r *ReflectRouter) Head(pattern string, handler interface{}, options []operations.Option, ...)
- func (r *ReflectRouter) MethodFunc(method, pattern string, handler interface{}, options []operations.Option, ...)
- func (r *ReflectRouter) Mount(pattern string, handler http.Handler)
- func (r *ReflectRouter) Options(pattern string, handler interface{}, options []operations.Option, ...)
- func (r *ReflectRouter) Patch(pattern string, handler interface{}, options []operations.Option, ...)
- func (r *ReflectRouter) Post(pattern string, handler interface{}, options []operations.Option, ...)
- func (r *ReflectRouter) Provide(fptr interface{}) error
- func (r *ReflectRouter) Put(pattern string, handler interface{}, options []operations.Option, ...)
- func (r *ReflectRouter) Route(pattern string, fn func(*ReflectRouter))
- func (r *ReflectRouter) SetParent(parent *ReflectRouter) *ReflectRouter
- func (r *ReflectRouter) Trace(pattern string, handler interface{}, options []operations.Option, ...)
- func (r *ReflectRouter) UseRouter(other *ReflectRouter) *ReflectRouter
- func (r *ReflectRouter) WithContainer(c *container.Container) *ReflectRouter
- func (r *ReflectRouter) WithHandler(fn RequestHandler) *ReflectRouter
- func (r *ReflectRouter) WithHooks(h Hooks) *ReflectRouter
- func (r *ReflectRouter) WithInfo(info openapi.Info) *ReflectRouter
- type RequestHandler
Constants ¶
This section is empty.
Variables ¶
var ErrRequiredJSONBody = fmt.Errorf("expected a request body")
Functions ¶
func HandlerFromFn ¶
func HandlerFromFn(fptr interface{}, fn RequestHandler, components openapi.Components, c *container.Container) (http.HandlerFunc, error)
HandlerFromFn takes in any function matching the following criteria: 1. Takes the following as input:
- context.Context
- *http.Request
- http.ResponseWriter
- any other type that is passed in via the ArgCreators map
2. Returns up to two responses
- last return of this function must be an error
The second argument is a function to ErrorHandler to handle any errors during the http.Handler All arguments will be automatically created and supplied to the function. Only loads params and one json body schema in the components.
func HandlerFromFnDefault ¶
func HandlerFromFnDefault(fnPtr interface{}, fn RequestHandler, components openapi.Components) (http.HandlerFunc, error)
Types ¶
type Hooks ¶
type Hooks struct { // BeforeOptions is called before the options are passed into the operation. // The returned operation will be used in place of the original BeforeOptions func(method, pattern string, handler interface{}, options []operations.Option) (operations.Options, error) // BeforeMiddleware is called before the handler is wrapped with the middleware. // The returned middleware will be used in place of the original BeforeMiddleware func(method, pattern string, handler interface{}, c *ReflectRouter, middleware []Middleware) ([]Middleware, error) }
type QueryParamError ¶
func (QueryParamError) Error ¶
func (e QueryParamError) Error() string
type ReflectRouter ¶
func (*ReflectRouter) Connect ¶
func (r *ReflectRouter) Connect(pattern string, handler interface{}, options []operations.Option, middleware ...Middleware)
func (*ReflectRouter) Container ¶
func (r *ReflectRouter) Container() *container.Container
FIXME: remove this?
func (*ReflectRouter) Delete ¶
func (r *ReflectRouter) Delete(pattern string, handler interface{}, options []operations.Option, middleware ...Middleware)
func (*ReflectRouter) Get ¶
func (r *ReflectRouter) Get(pattern string, handler interface{}, options []operations.Option, middleware ...Middleware)
func (*ReflectRouter) Head ¶
func (r *ReflectRouter) Head(pattern string, handler interface{}, options []operations.Option, middleware ...Middleware)
func (*ReflectRouter) MethodFunc ¶
func (r *ReflectRouter) MethodFunc(method, pattern string, handler interface{}, options []operations.Option, middleware ...Middleware)
MethodFunc adds routes for `pattern` that matches the `method` HTTP method. Middleware are executed from first to last
func (*ReflectRouter) Mount ¶
func (r *ReflectRouter) Mount(pattern string, handler http.Handler)
Mount attaches another http.Handler along ./pattern/*
func (*ReflectRouter) Options ¶
func (r *ReflectRouter) Options(pattern string, handler interface{}, options []operations.Option, middleware ...Middleware)
func (*ReflectRouter) Patch ¶
func (r *ReflectRouter) Patch(pattern string, handler interface{}, options []operations.Option, middleware ...Middleware)
func (*ReflectRouter) Post ¶
func (r *ReflectRouter) Post(pattern string, handler interface{}, options []operations.Option, middleware ...Middleware)
func (*ReflectRouter) Provide ¶
func (r *ReflectRouter) Provide(fptr interface{}) error
func (*ReflectRouter) Put ¶
func (r *ReflectRouter) Put(pattern string, handler interface{}, options []operations.Option, middleware ...Middleware)
func (*ReflectRouter) Route ¶
func (r *ReflectRouter) Route(pattern string, fn func(*ReflectRouter))
Route mounts a sub-Router along a `pattern“ string.
func (*ReflectRouter) SetParent ¶
func (r *ReflectRouter) SetParent(parent *ReflectRouter) *ReflectRouter
func (*ReflectRouter) Trace ¶
func (r *ReflectRouter) Trace(pattern string, handler interface{}, options []operations.Option, middleware ...Middleware)
func (*ReflectRouter) UseRouter ¶
func (r *ReflectRouter) UseRouter(other *ReflectRouter) *ReflectRouter
UseRouter copies over the routes and swagger info from the other router.
func (*ReflectRouter) WithContainer ¶
func (r *ReflectRouter) WithContainer(c *container.Container) *ReflectRouter
func (*ReflectRouter) WithHandler ¶
func (r *ReflectRouter) WithHandler(fn RequestHandler) *ReflectRouter
func (*ReflectRouter) WithHooks ¶
func (r *ReflectRouter) WithHooks(h Hooks) *ReflectRouter
func (*ReflectRouter) WithInfo ¶
func (r *ReflectRouter) WithInfo(info openapi.Info) *ReflectRouter
type RequestHandler ¶
type RequestHandler func(w http.ResponseWriter, r *http.Request, response interface{}, err error)