Documentation
¶
Index ¶
- Variables
- func AddSlash(path string) string
- func ChainHandlers(lastHandler http.Handler, handlers ...func(http.Handler) http.Handler) http.Handler
- type Logger
- type Router
- func (r *Router) ExactHandleFunc(relativePath string, handler http.HandlerFunc, ...)
- func (r *Router) FullPath() string
- func (r *Router) GetMiddlewares() *[]func(http.Handler) http.Handler
- func (r *Router) HandleFunc(relativePath string, handler http.HandlerFunc, ...)
- func (r *Router) Handler() http.Handler
- func (r *Router) Mux() *http.ServeMux
- func (r *Router) NewGroup(relativePath string, middlewares ...func(next http.Handler) http.Handler) *Router
- func (r *Router) RegisterExactRoute(relativePath string, handler http.HandlerFunc, ...)
- func (r *Router) RegisterGroup(router *Router)
- func (r *Router) RegisterHandler(relativePath string, handler http.Handler)
- func (r *Router) RegisterRoute(relativePath string, handler http.HandlerFunc, ...)
- func (r *Router) RelativePath() string
- type RouterWrapper
Constants ¶
This section is empty.
Variables ¶
var ( ErrNilRouter = errors.New("router cannot be nil") ErrNilMiddleware = "%s: middleware at index %d cannot be nil" )
Functions ¶
Types ¶
type Logger ¶ added in v0.4.0
type Logger struct {
// contains filtered or unexported fields
}
Logger is the logger for router
func NewLogger ¶ added in v0.4.0
func NewLogger(header string, modeLogger gologgermode.Logger) (*Logger, error)
NewLogger is the logger for the router
func (*Logger) RegisterRoute ¶ added in v0.4.0
RegisterRoute registers a route
func (*Logger) RegisterRouteGroup ¶ added in v0.4.0
RegisterRouteGroup registers a route group
type Router ¶ added in v0.2.2
type Router struct {
// contains filtered or unexported fields
}
Router is the route group struct
func NewBaseRouter ¶ added in v0.4.2
func NewBaseRouter( mode *goflagsmode.Flag, logger *Logger, middlewares ...func(next http.Handler) http.Handler, ) (*Router, error)
NewBaseRouter creates a new base router
func NewGroup ¶
func NewGroup( baseRouter *Router, relativePath string, middlewares ...func(next http.Handler) http.Handler, ) (*Router, error)
NewGroup creates a new router group
func NewRouter ¶ added in v0.2.2
func NewRouter( path string, mode *goflagsmode.Flag, logger *Logger, middlewares ...func(next http.Handler) http.Handler, ) (*Router, error)
NewRouter creates a new router
func (*Router) ExactHandleFunc ¶ added in v0.7.24
func (r *Router) ExactHandleFunc( relativePath string, handler http.HandlerFunc, middlewares ...func(http.Handler) http.Handler, )
ExactHandleFunc registers a new route with a path, the handler function and the middlewares
func (*Router) GetMiddlewares ¶ added in v0.7.10
GetMiddlewares returns the middlewares
func (*Router) HandleFunc ¶ added in v0.2.2
func (r *Router) HandleFunc( relativePath string, handler http.HandlerFunc, middlewares ...func(http.Handler) http.Handler, )
HandleFunc registers a new route with a path, the handler function and the middlewares
func (*Router) NewGroup ¶ added in v0.4.2
func (r *Router) NewGroup( relativePath string, middlewares ...func(next http.Handler) http.Handler, ) *Router
NewGroup creates a new router group with a path
func (*Router) RegisterExactRoute ¶ added in v0.7.24
func (r *Router) RegisterExactRoute( relativePath string, handler http.HandlerFunc, middlewares ...func(http.Handler) http.Handler, )
RegisterExactRoute registers a new route with a path, the handler function and the middlewares. This matches the exact path
func (*Router) RegisterGroup ¶ added in v0.4.2
RegisterGroup registers a new router group with a path and a router
func (*Router) RegisterHandler ¶ added in v0.2.2
RegisterHandler registers a new route group with a path and a handler function
func (*Router) RegisterRoute ¶ added in v0.2.2
func (r *Router) RegisterRoute( relativePath string, handler http.HandlerFunc, middlewares ...func(http.Handler) http.Handler, )
RegisterRoute registers a new route with a path, the handler function and the middlewares. This does not match the exact path
func (*Router) RelativePath ¶ added in v0.7.22
RelativePath returns the relative path
type RouterWrapper ¶ added in v0.2.2
type RouterWrapper interface {
Handler() http.Handler
Mux() *http.ServeMux
GetMiddlewares() *[]func(http.Handler) http.Handler
HandleFunc(
relativePath string,
handler http.HandlerFunc,
middlewares ...func(next http.Handler) http.Handler,
)
ExactHandleFunc(
relativePath string,
handler http.HandlerFunc,
middlewares ...func(next http.Handler) http.Handler,
)
RegisterRoute(
relativePath string,
handler http.HandlerFunc,
middlewares ...func(next http.Handler) http.Handler,
)
RegisterExactRoute(
relativePath string,
handler http.HandlerFunc,
middlewares ...func(next http.Handler) http.Handler,
)
RegisterHandler(relativePath string, handler http.Handler)
NewGroup(
relativePath string,
middlewares ...func(next http.Handler) http.Handler,
) *Router
RegisterGroup(router *Router)
RelativePath() string
FullPath() string
}
RouterWrapper is the interface for the routes