Documentation
¶
Index ¶
- func Dump()
- func Handler(rootController Controller) http.Handler
- func Url(routeRef any, args ...any) (r string)
- func UrlE(routeRef any, args ...any) (r string, err error)
- type Controller
- type ControllerBase
- type MbrContext
- func (ctx *MbrContext) Error(error string, args ...any)
- func (ctx *MbrContext) ErrorWithCode(code int, error string, args ...any)
- func (ctx *MbrContext) Get(key string) any
- func (ctx *MbrContext) GetOk(key string) (any, bool)
- func (ctx *MbrContext) IsRedirect() bool
- func (ctx *MbrContext) Redirect(code int, url string)
- func (ctx *MbrContext) RedirectRoute(code int, routeRef any, args ...any)
- func (ctx *MbrContext) Request() *http.Request
- func (ctx *MbrContext) Route() *Route
- func (ctx *MbrContext) Set(key string, value any) *MbrContext
- func (ctx *MbrContext) Writer() http.ResponseWriter
- type Middleware
- type MiddlewareList
- type Route
- type RouterHandleFunc
- type WithMiddlewareList
- type WithMiddlewareListBase
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Handler ¶
func Handler(rootController Controller) http.Handler
Types ¶
type Controller ¶
type Controller interface {
WithMiddlewareList
ParentControllers() []Controller
SetParentControllers(parents []Controller)
}
type ControllerBase ¶
type ControllerBase struct {
WithMiddlewareListBase
// contains filtered or unexported fields
}
func (*ControllerBase) ParentControllers ¶
func (ctrl *ControllerBase) ParentControllers() []Controller
func (*ControllerBase) SetParentControllers ¶
func (ctrl *ControllerBase) SetParentControllers(parents []Controller)
type MbrContext ¶
type MbrContext struct {
// contains filtered or unexported fields
}
func Context ¶
func Context(r *http.Request) *MbrContext
gets MbrContext from request's http.Context
func (*MbrContext) Error ¶
func (ctx *MbrContext) Error(error string, args ...any)
Issues http error "500 Internal server error"
func (*MbrContext) ErrorWithCode ¶
func (ctx *MbrContext) ErrorWithCode(code int, error string, args ...any)
Issues http error with given code
func (*MbrContext) Get ¶
func (ctx *MbrContext) Get(key string) any
func (*MbrContext) IsRedirect ¶
func (ctx *MbrContext) IsRedirect() bool
func (*MbrContext) Redirect ¶
func (ctx *MbrContext) Redirect(code int, url string)
Helper to issue https redirects
func (*MbrContext) RedirectRoute ¶
func (ctx *MbrContext) RedirectRoute(code int, routeRef any, args ...any)
Helper to issue https redirects. routeRef and args passed to UrlE()
func (*MbrContext) Request ¶
func (ctx *MbrContext) Request() *http.Request
func (*MbrContext) Route ¶
func (ctx *MbrContext) Route() *Route
func (*MbrContext) Set ¶
func (ctx *MbrContext) Set(key string, value any) *MbrContext
func (*MbrContext) Writer ¶
func (ctx *MbrContext) Writer() http.ResponseWriter
type Middleware ¶
standard net/http middleware alias
type MiddlewareList ¶
type MiddlewareList []Middleware
type Route ¶
type Route struct {
WithMiddlewareListBase
PathPattern string
Method string // empty = any, or space-separated methods list. examples "GET", "POST GET", "HEAD, GET"
HandleF RouterHandleFunc
ChildController Controller
StaticFS fs.FS
FileFromFS string
// contains filtered or unexported fields
}
func (*Route) MethodList ¶
type RouterHandleFunc ¶
type RouterHandleFunc func(ctx *MbrContext) any
type WithMiddlewareList ¶
type WithMiddlewareList interface {
With(middleware Middleware)
Middlewares() MiddlewareList
ApplyMiddlewares(http.Handler) http.Handler
}
type WithMiddlewareListBase ¶
type WithMiddlewareListBase struct {
// contains filtered or unexported fields
}
func (*WithMiddlewareListBase) ApplyMiddlewares ¶
func (o *WithMiddlewareListBase) ApplyMiddlewares(handler http.Handler) http.Handler
func (*WithMiddlewareListBase) Middlewares ¶
func (o *WithMiddlewareListBase) Middlewares() MiddlewareList
func (*WithMiddlewareListBase) With ¶
func (o *WithMiddlewareListBase) With(middleware Middleware)
Click to show internal directories.
Click to hide internal directories.