Documentation
¶
Index ¶
- Constants
- Variables
- func FastHttpHandlerFromHttp(req *content.FastHttpRequest, h http.Handler) contract.ResponseContract
- func NetHttpHandlerFromHttp(request *content.NetHttpRequest, h http.Handler) contract.ResponseContract
- type CRUDHandler
- type GroupHandler
- type Handler
- type RequestResolver
- 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) CRUD(path string, handler CRUDHandler, middleware ...string)
- func (w *Wrapper) Delete(path string, handler interface{}) *routesHolder
- func (w *Wrapper) Get(path string, handler interface{}) *routesHolder
- func (w *Wrapper) Group(g GroupHandler, prefix string, middleware ...string)
- 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(req contract.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 (w *Wrapper) ResolveRequest(rs RequestResolver)
- func (r Wrapper) Routes() map[string][]*paramRoute
Constants ¶
Variables ¶
View Source
var DefaultResultHandler = func(val []reflect.Value, err error) contract.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() _, isErr := e.(error) if isErr && e != nil { return content.ErrResponseFromError(err, 500, nil) } } data := val[0].Interface() return convertResponse(data) }
View Source
var MethodSplitter = "@"
Functions ¶
func FastHttpHandlerFromHttp ¶
func FastHttpHandlerFromHttp(req *content.FastHttpRequest, h http.Handler) contract.ResponseContract
func NetHttpHandlerFromHttp ¶
func NetHttpHandlerFromHttp(request *content.NetHttpRequest, h http.Handler) contract.ResponseContract
Types ¶
type CRUDHandler ¶
type CRUDHandler interface {
Index(request contract.RequestContract) json.Marshaler
Show(request contract.RequestContract, id int64) json.Marshaler
Store(request contract.RequestContract) contract.ResponseContract
Update(request contract.RequestContract, id int64) contract.ResponseContract
Delete(request contract.RequestContract, id int64) contract.ResponseContract
}
type GroupHandler ¶
type GroupHandler func(r *Wrapper)
type Handler ¶
type Handler interface {
HandleRoute(r contract.RequestContract) contract.ResponseContract
}
type RequestResolver ¶
type RequestResolver interface {
ResolveRequest(r contract.RequestContract, runtime *kernel.Application)
}
type ResultHandler ¶
type ResultHandler func(val []reflect.Value, err error) contract.ResponseContract
ResultHandler handle return result
type RouteHandler ¶
type RouteHandler func(r contract.RequestContract) contract.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 NewWrapper(app *kernel.Application) *Wrapper
func (*Wrapper) BindController ¶
BindController bind single controller
func (*Wrapper) BindControllers ¶
BindControllers bind controllers
func (*Wrapper) CRUD ¶
func (w *Wrapper) CRUD(path string, handler CRUDHandler, middleware ...string)
CRUD register simple crud routes
func (*Wrapper) Group ¶
func (w *Wrapper) Group(g GroupHandler, prefix string, middleware ...string)
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(req contract.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,RequestContract,[]byte or JsonAble
func (*Wrapper) ResolveRequest ¶
func (w *Wrapper) ResolveRequest(rs RequestResolver)
Click to show internal directories.
Click to hide internal directories.