Documentation ¶
Index ¶
- Constants
- Variables
- func AppendSlash(path string) string
- func FastHttpHandlerFromHttp(req *content.FastHttpRequest, h http.Handler) contracts.ResponseContract
- func JoinPaths(paths ...string) string
- func NetHttpHandlerFromHttp(request *content.NetHttpRequest, h http.Handler) contracts.ResponseContract
- type ContainerRegister
- type GroupHandler
- type Handler
- type ParamRoute
- func (p *ParamRoute) Handler() RouteHandler
- func (p *ParamRoute) IsValid() bool
- func (p *ParamRoute) Middleware() []string
- func (p *ParamRoute) Name() string
- func (p *ParamRoute) Partials() []partial
- func (p *ParamRoute) Path() string
- func (p *ParamRoute) PipeFuncs() []pipeline.PipeFunc
- func (p *ParamRoute) SetMiddleware(middleware []string) *ParamRoute
- type ParamSlice
- type Params
- type ResultHandler
- type RouteHandler
- type Wrapper
- func (w *Wrapper) BindController(name string, controller interface{})
- func (w *Wrapper) BindControllers(controllers map[string]interface{})
- func (w *Wrapper) Delete(path string, handler interface{}) *routesHolder
- func (w *Wrapper) FastHttpFileServer(path, root string, stripSlashes int) *routesHolder
- func (w *Wrapper) Get(path string, handler interface{}) *routesHolder
- func (w *Wrapper) Group(g GroupHandler, prefix ...string) *routesHolder
- func (r Wrapper) HandleDelete(path string, handler RouteHandler) *routesHolder
- func (r Wrapper) HandleGet(path string, handler RouteHandler) *routesHolder
- func (r Wrapper) HandlePatch(path string, handler RouteHandler) *routesHolder
- func (r Wrapper) HandlePost(path string, handler RouteHandler) *routesHolder
- func (r Wrapper) HandlePut(path string, handler RouteHandler) *routesHolder
- func (r Wrapper) Match(request contracts.RequestContract) *ParamRoute
- func (r Wrapper) MatchBytes(request contracts.RequestContract) *ParamRoute
- func (r Wrapper) MatchString(request contracts.RequestContract) *ParamRoute
- func (r Wrapper) MatchTree(request contracts.RequestContract) *ParamRoute
- func (w *Wrapper) Patch(path string, handler interface{}) *routesHolder
- func (w *Wrapper) Post(path string, handler interface{}) *routesHolder
- func (w *Wrapper) Put(path string, handler interface{}) *routesHolder
- func (r Wrapper) Register(method int, path string, handler RouteHandler) *routesHolder
- func (w *Wrapper) RegisterAction(method int, path string, handler interface{}) *routesHolder
- func (r Wrapper) Routes() map[string][]*ParamRoute
Constants ¶
Variables ¶
View Source
var DefaultResultHandler = func(val []reflect.Value, err error) contracts.ResponseContract { if err != nil { return content.ErrResponseFromError(err, 500, nil) } if len(val) < 1 { return content.TextResponse("", 200) } if len(val) > 1 { e := val[1].Interface() er, isErr := e.(error) if isErr && e != nil { return content.ErrResponseFromError(er, 500, nil) } } data := val[0].Interface() return convertResponse(data) }
View Source
var MethodSplitter = "@"
View Source
var NotFoundHandler = func(r contracts.RequestContract) contracts.ResponseContract { return content.ErrResponseFromError(errors.NotFound("Not Found"), 404, nil) }
View Source
var ResponseFallbacker = func(data interface{}) contracts.ResponseContract { return content.JsonResponse(data, 200, nil) }
Functions ¶
func AppendSlash ¶
func FastHttpHandlerFromHttp ¶
func FastHttpHandlerFromHttp(req *content.FastHttpRequest, h http.Handler) contracts.ResponseContract
func NetHttpHandlerFromHttp ¶
func NetHttpHandlerFromHttp(request *content.NetHttpRequest, h http.Handler) contracts.ResponseContract
Types ¶
type ContainerRegister ¶
type ContainerRegister func(request contracts.RequestContract) container.Interface
type GroupHandler ¶
type GroupHandler func(r *Wrapper)
type Handler ¶
type Handler interface {
HandleRoute(r contracts.RequestContract) contracts.ResponseContract
}
type ParamRoute ¶ added in v1.0.0
type ParamRoute struct {
// contains filtered or unexported fields
}
func (*ParamRoute) Handler ¶ added in v1.0.0
func (p *ParamRoute) Handler() RouteHandler
Handler route handler
func (*ParamRoute) IsValid ¶ added in v1.0.0
func (p *ParamRoute) IsValid() bool
func (*ParamRoute) Middleware ¶ added in v1.0.0
func (p *ParamRoute) Middleware() []string
func (*ParamRoute) Partials ¶ added in v1.0.0
func (p *ParamRoute) Partials() []partial
Partials partials of route path
func (*ParamRoute) PipeFuncs ¶ added in v1.0.0
func (p *ParamRoute) PipeFuncs() []pipeline.PipeFunc
PipeFuncs return pipeline middleware
func (*ParamRoute) SetMiddleware ¶ added in v1.0.0
func (p *ParamRoute) SetMiddleware(middleware []string) *ParamRoute
type ParamSlice ¶
type ParamSlice [][]byte
type ResultHandler ¶
type ResultHandler func(val []reflect.Value, err error) contracts.ResponseContract
ResultHandler handle return result
type RouteHandler ¶
type RouteHandler func(r contracts.RequestContract) contracts.ResponseContract
RouteHandler normal route handler
func NewRouteHandlerFromHttp ¶
func NewRouteHandlerFromHttp(h http.Handler) RouteHandler
type Wrapper ¶
type Wrapper struct { ResultHandler ResultHandler // contains filtered or unexported fields }
func NewWrapper ¶
func (*Wrapper) BindController ¶
BindController bind single controller
func (*Wrapper) BindControllers ¶
BindControllers bind controllers
func (*Wrapper) FastHttpFileServer ¶
func (*Wrapper) Group ¶
func (w *Wrapper) Group(g GroupHandler, prefix ...string) *routesHolder
func (Wrapper) HandleDelete ¶
func (r Wrapper) HandleDelete(path string, handler RouteHandler) *routesHolder
func (Wrapper) HandleGet ¶
func (r Wrapper) HandleGet(path string, handler RouteHandler) *routesHolder
HandleGet get method with route handler
func (Wrapper) HandlePatch ¶
func (r Wrapper) HandlePatch(path string, handler RouteHandler) *routesHolder
func (Wrapper) HandlePost ¶
func (r Wrapper) HandlePost(path string, handler RouteHandler) *routesHolder
func (Wrapper) HandlePut ¶
func (r Wrapper) HandlePut(path string, handler RouteHandler) *routesHolder
func (Wrapper) Match ¶
func (r Wrapper) Match(request contracts.RequestContract) *ParamRoute
func (Wrapper) MatchBytes ¶
func (r Wrapper) MatchBytes(request contracts.RequestContract) *ParamRoute
Depracated MatchBytes, using MatchTree
func (Wrapper) MatchString ¶
func (r Wrapper) MatchString(request contracts.RequestContract) *ParamRoute
Depracated MatchString, using MatchTree
func (Wrapper) MatchTree ¶
func (r Wrapper) MatchTree(request contracts.RequestContract) *ParamRoute
func (Wrapper) Register ¶
func (r Wrapper) Register(method int, path string, handler RouteHandler) *routesHolder
Register register route
func (*Wrapper) RegisterAction ¶
RegisterAction register route with giving handler
'handler' can be string(eg: "home@Index",), RouteHandler or any func returns string,ResponseContract,[]byte or struct (auto convert to json response)
func (Wrapper) Routes ¶
func (r Wrapper) Routes() map[string][]*ParamRoute
Click to show internal directories.
Click to hide internal directories.