Documentation ¶
Index ¶
- Variables
- type ArgsInjector
- type BindingCallback
- type CommandDown
- type CommandRoutes
- type CommandServe
- type CommandUp
- type ErrorsHandler
- type ErrorsHandlerInterface
- type FormRequestValidator
- type GroupRoute
- type Handler
- type JSONRequestValidator
- type Middleware
- type ParamsRequestValidator
- type Pipeline
- type QueryRequestValidator
- type Request
- func (r *Request) BaseRequest() *net_http.Request
- func (r *Request) Cookie(name string) string
- func (r *Request) FormValues() url.Values
- func (r *Request) HasCookie(name string) bool
- func (r *Request) Header(name string) string
- func (r *Request) HeaderContains(header, substring string) bool
- func (r *Request) IP() string
- func (r *Request) IsAjax() bool
- func (r *Request) Method() string
- func (r *Request) Param(name string) interface{}
- func (r *Request) ParamValues() url.Values
- func (r *Request) Query() url.Values
- func (r *Request) ReadForm(target interface{}) error
- func (r *Request) ReadJSON(target interface{}) error
- func (r *Request) ReadParams(target interface{}) error
- func (r *Request) ReadQuery(target interface{}) error
- func (r *Request) Referer() string
- func (r *Request) URL() string
- func (r *Request) WantsHTML() bool
- func (r *Request) WantsJSON() bool
- func (r *Request) WantsPlainText() bool
- type RequestsInjector
- type Route
- type RouteParamsInjector
- type Router
- func (r *Router) Bind(param string, callback BindingCallback)
- func (r *Router) Bootstrap() *Router
- func (r *Router) DELETE(path string) *Route
- func (r *Router) GET(path string) *Route
- func (r *Router) GetHTTPRouter() *httprouter.Router
- func (r *Router) GetMiddleware() []Middleware
- func (r *Router) GetRoutes() []*Route
- func (r *Router) Group(path string, callback func(), middleware ...Middleware)
- func (r *Router) Listen(listen string) error
- func (r *Router) Middleware(middleware ...Middleware) *Router
- func (r *Router) PATCH(path string) *Route
- func (r *Router) POST(path string) *Route
- func (r *Router) PUT(path string) *Route
- func (r *Router) SetArgsInjectors(injectors ...ArgsInjector)
- func (r *Router) SetMethodNotAllowedHandler(handler net_http.HandlerFunc) *Router
- func (r *Router) SetNotFoundHandler(handler net_http.HandlerFunc) *Router
- type ServiceProvider
Constants ¶
This section is empty.
Variables ¶
var FacadeWrapper = &larago.Facade{}
FacadeWrapper for facade.
Functions ¶
This section is empty.
Types ¶
type ArgsInjector ¶
type ArgsInjector interface { // Injects custom params to for the action. Inject(params []interface{}, request *Request) ([]interface{}, error) }
ArgsInjector uses as an external source of arguments that can be injected in the route action handler.
type BindingCallback ¶
BindingCallback is a function to resolve binded param value.
type CommandDown ¶
type CommandDown struct { Application *larago.Application Logger *logger.Logger }
CommandDown to apply DB changes.
func (*CommandDown) GetCommand ¶
func (c *CommandDown) GetCommand() cli.Command
GetCommand for the cli to register.
type CommandRoutes ¶
CommandRoutes to apply DB changes.
func (*CommandRoutes) GetCommand ¶
func (c *CommandRoutes) GetCommand() cli.Command
GetCommand for the cli to register.
type CommandServe ¶
type CommandServe struct { Router *Router Config *larago.ConfigRepository // contains filtered or unexported fields }
CommandServe command.
func (*CommandServe) GetCommand ¶
func (c *CommandServe) GetCommand() cli.Command
GetCommand for the cli to register.
type CommandUp ¶
type CommandUp struct { Application *larago.Application Logger *logger.Logger }
CommandUp to apply DB changes.
func (*CommandUp) GetCommand ¶
GetCommand for the cli to register.
type ErrorsHandler ¶
type ErrorsHandler struct { Logger *logger.Logger Debug bool `di:"Config.App.Debug"` ValidationErrorsConverter validation.ErrorsConverter }
ErrorsHandler to handle errors during http calls.
type ErrorsHandlerInterface ¶
type ErrorsHandlerInterface interface { // Report error to logger. Report(err error) // Render error to return to the client. Render(request *Request, err error) responses.Response }
ErrorsHandlerInterface for every handler to resolve errors during http calls..
type FormRequestValidator ¶
type FormRequestValidator interface {
ValidateForm() error
}
FormRequestValidator interface for form requests.
type GroupRoute ¶
type GroupRoute struct { Path string Middlewares []Middleware }
GroupRoute struct.
func (*GroupRoute) Middleware ¶
func (r *GroupRoute) Middleware(middleware ...Middleware) *GroupRoute
Middleware sets middleware for GroupRoute.
type JSONRequestValidator ¶
type JSONRequestValidator interface {
ValidateJSON() error
}
JSONRequestValidator interface for json requests.
type Middleware ¶
type Middleware interface { // Handle request. Handle(request *Request, next Handler) responses.Response }
Middleware interface.
type ParamsRequestValidator ¶
type ParamsRequestValidator interface {
ValidateParams() error
}
ParamsRequestValidator interface for url params.
type Pipeline ¶
type Pipeline struct {
// contains filtered or unexported fields
}
Pipeline struct.
func NewPipeline ¶
NewPipeline constructor.
func (*Pipeline) Through ¶
func (p *Pipeline) Through(middleware []Middleware) *Pipeline
Through what pipes run passable.
type QueryRequestValidator ¶
type QueryRequestValidator interface {
ValidateQuery() error
}
QueryRequestValidator interface for query.
type Request ¶
type Request struct { Route *Route Params httprouter.Params Bindings []interface{} // contains filtered or unexported fields }
Request handles http request.
func (*Request) BaseRequest ¶
BaseRequest returns base net/http request.
func (*Request) FormValues ¶
FormValues returns all form values.
func (*Request) HeaderContains ¶
HeaderContains checks if header contains requested substring.
func (*Request) ParamValues ¶
ParamValues returns all param values in url.Values format.
func (*Request) ReadParams ¶
ReadParams unmarshal url params to the structure.
func (*Request) WantsPlainText ¶
WantsPlainText checks if client wants plain text answer.
type RequestsInjector ¶
type RequestsInjector struct{}
RequestsInjector populates and validates
func (*RequestsInjector) Inject ¶
func (rv *RequestsInjector) Inject(params []interface{}, request *Request) ([]interface{}, error)
Inject custom params to for the action.
type Route ¶
type Route struct { Method string Path string Name string Middlewares []Middleware Handler interface{} ToValidate []validation.SelfValidator }
Route struct.
func (*Route) Middleware ¶
func (r *Route) Middleware(middleware ...Middleware) *Route
Middleware sets middleware for route.
func (*Route) Validate ¶
func (r *Route) Validate(requests ...validation.SelfValidator) *Route
Validate request.
type RouteParamsInjector ¶
type RouteParamsInjector struct{}
RouteParamsInjector injects raw route params.
func (*RouteParamsInjector) Inject ¶
func (i *RouteParamsInjector) Inject(params []interface{}, request *Request) ([]interface{}, error)
Inject custom params to for the action.
type Router ¶
type Router struct { // Dependencies Container *container.Container Logger *logger.Logger Events *EventBus.EventBus ErrorsHandler ErrorsHandlerInterface Config larago.Config // contains filtered or unexported fields }
Router struct.
func (*Router) Bind ¶
func (r *Router) Bind(param string, callback BindingCallback)
Bind route param to the specified callback return value.
func (*Router) GetHTTPRouter ¶
func (r *Router) GetHTTPRouter() *httprouter.Router
GetHTTPRouter returns httprouter instance.
func (*Router) GetMiddleware ¶
func (r *Router) GetMiddleware() []Middleware
GetMiddleware returns all glbally registered middleware.
func (*Router) Group ¶
func (r *Router) Group(path string, callback func(), middleware ...Middleware)
Group routes.
func (*Router) Listen ¶
Listen to requests. Do not forget to run Bootstrap in order to prepare and set routes.
func (*Router) Middleware ¶
func (r *Router) Middleware(middleware ...Middleware) *Router
Middleware sets global middleware to run over every request.
func (*Router) SetArgsInjectors ¶
func (r *Router) SetArgsInjectors(injectors ...ArgsInjector)
SetArgsInjectors sets additional components that can inject more custom arguments to route action handler.
func (*Router) SetMethodNotAllowedHandler ¶
func (r *Router) SetMethodNotAllowedHandler(handler net_http.HandlerFunc) *Router
SetMethodNotAllowedHandler allowes to set custom MethodNotAllowed handler.
func (*Router) SetNotFoundHandler ¶
func (r *Router) SetNotFoundHandler(handler net_http.HandlerFunc) *Router
SetNotFoundHandler allowes to set custom NotFound handler.
type ServiceProvider ¶
type ServiceProvider struct{}
ServiceProvider struct.
func (*ServiceProvider) Register ¶
func (p *ServiceProvider) Register(application *larago.Application)
Register service.