Documentation ¶
Index ¶
- type Config
- type Handler
- type Router
- func (r *Router) Delete(path string, handler http.HandlerFunc)
- func (r *Router) Get(path string, handler http.HandlerFunc)
- func (r *Router) Handle(method, path string, h http.Handler)
- func (r *Router) HandleFunc(method, path string, hf http.HandlerFunc)
- func (ro *Router) Handler() Handler
- func (r *Router) Patch(path string, handler http.HandlerFunc)
- func (r *Router) Post(path string, handler http.HandlerFunc)
- func (r *Router) Put(path string, handler http.HandlerFunc)
- func (r *Router) ServeFS(path string, root http.FileSystem, mds ...handler.Middleware)
- func (r *Router) ServeFSWithGzip(path string, root http.FileSystem, mds ...handler.Middleware)
- func (r *Router) Static(path string, dst string, mds ...handler.Middleware)
- func (r *Router) StaticGZIP(path string, dst string, mds ...handler.Middleware)
- type RoutesGroup
- func (g *RoutesGroup) Delete(path string, handler http.HandlerFunc)
- func (g *RoutesGroup) Get(path string, handler http.HandlerFunc)
- func (g *RoutesGroup) Group(path string, mds ...handler.Middleware) *RoutesGroup
- func (g *RoutesGroup) HandleFunc(method, path string, handler http.HandlerFunc)
- func (g *RoutesGroup) Handler() Handler
- func (g *RoutesGroup) Patch(path string, handler http.HandlerFunc)
- func (g *RoutesGroup) Post(path string, handler http.HandlerFunc)
- func (g *RoutesGroup) Put(path string, handler http.HandlerFunc)
- func (g *RoutesGroup) ServeFS(path string, root http.FileSystem)
- func (g *RoutesGroup) ServeFSWithGzip(path string, root http.FileSystem)
- func (g *RoutesGroup) Static(path string, dst string)
- func (g *RoutesGroup) StaticGZIP(path string, dst string)
- func (g *RoutesGroup) Use(mds ...handler.Middleware)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Debug bool Limiter struct { Rps float64 Burst int Enabled bool } CORS struct { TrustedOrigins []string } Metrics bool }
Config is the configuration for the router
type Handler ¶ added in v0.4.3
type Handler struct {
// contains filtered or unexported fields
}
Handler serveHTTP
type Router ¶ added in v0.2.0
type Router struct {
// contains filtered or unexported fields
}
Router ..
func (*Router) Delete ¶ added in v0.2.0
func (r *Router) Delete(path string, handler http.HandlerFunc)
Delete is a shortcut for HandleFunc(http.MethodDelete, path, handler)
func (*Router) Get ¶ added in v0.2.0
func (r *Router) Get(path string, handler http.HandlerFunc)
Get is a shortcut for HandleFunc(http.MethodGet, path, handler)
func (*Router) HandleFunc ¶ added in v0.2.0
func (r *Router) HandleFunc(method, path string, hf http.HandlerFunc)
func (*Router) Patch ¶ added in v0.2.0
func (r *Router) Patch(path string, handler http.HandlerFunc)
Patch is a shortcut for HandleFunc(http.MethodPatch, path, handler)
func (*Router) Post ¶ added in v0.2.0
func (r *Router) Post(path string, handler http.HandlerFunc)
Post is a shortcut for HandleFunc(http.MethodPost, path, handler)
func (*Router) Put ¶ added in v0.2.0
func (r *Router) Put(path string, handler http.HandlerFunc)
Put is a shortcut for HandleFunc(http.MethodPut, path, handler)
func (*Router) ServeFS ¶ added in v0.4.15
func (r *Router) ServeFS(path string, root http.FileSystem, mds ...handler.Middleware)
func (*Router) ServeFSWithGzip ¶ added in v0.4.15
func (r *Router) ServeFSWithGzip(path string, root http.FileSystem, mds ...handler.Middleware)
func (*Router) Static ¶ added in v0.2.0
func (r *Router) Static(path string, dst string, mds ...handler.Middleware)
Static serve dir dest
func (*Router) StaticGZIP ¶ added in v0.3.2
func (r *Router) StaticGZIP(path string, dst string, mds ...handler.Middleware)
StaticGZIP serve dir dest with Gzip middleware
type RoutesGroup ¶
type RoutesGroup struct {
// contains filtered or unexported fields
}
RoutesGroup is a group of routes
func DefaultRoutesGroup ¶ added in v0.0.15
func DefaultRoutesGroup() *RoutesGroup
DefaultRoutesGroup return a new routesgroup with default router config
func NewRoutesGroup ¶ added in v0.0.15
func NewRoutesGroup(conf *Config) (*RoutesGroup, error)
NewRoutesGroup return a new routesgroup
func (*RoutesGroup) Delete ¶
func (g *RoutesGroup) Delete(path string, handler http.HandlerFunc)
Delete is a shortcut for NewHandler(http.MethodDelete, path, handler)
func (*RoutesGroup) Get ¶
func (g *RoutesGroup) Get(path string, handler http.HandlerFunc)
Get is a shortcut for NewHandler(http.MethodGet, path, handler)
func (*RoutesGroup) Group ¶
func (g *RoutesGroup) Group(path string, mds ...handler.Middleware) *RoutesGroup
Group add a prefix to all path, for each Gropu call prefix and middleware will accumulate
func (*RoutesGroup) HandleFunc ¶ added in v0.2.0
func (g *RoutesGroup) HandleFunc(method, path string, handler http.HandlerFunc)
HandleFunc handle new http request
func (*RoutesGroup) Handler ¶ added in v0.4.3
func (g *RoutesGroup) Handler() Handler
Handler return http.Handler
func (*RoutesGroup) Patch ¶
func (g *RoutesGroup) Patch(path string, handler http.HandlerFunc)
Patch is a shortcut for NewHandler(http.MethodPatch, path, handler)
func (*RoutesGroup) Post ¶
func (g *RoutesGroup) Post(path string, handler http.HandlerFunc)
Post is a shortcut for NewHandler(http.MethodPost, path, handler)
func (*RoutesGroup) Put ¶
func (g *RoutesGroup) Put(path string, handler http.HandlerFunc)
Put is a shortcut for NewHandler(http.MethodPut, path, handler)
func (*RoutesGroup) ServeFS ¶ added in v0.4.15
func (g *RoutesGroup) ServeFS(path string, root http.FileSystem)
ServerFs ...
func (*RoutesGroup) ServeFSWithGzip ¶ added in v0.4.15
func (g *RoutesGroup) ServeFSWithGzip(path string, root http.FileSystem)
ServFSWithGzip ...
func (*RoutesGroup) Static ¶
func (g *RoutesGroup) Static(path string, dst string)
Static serve dir dest
func (*RoutesGroup) StaticGZIP ¶ added in v0.3.2
func (g *RoutesGroup) StaticGZIP(path string, dst string)
StaticGZIP serve dir dest with Gzip middleware
func (*RoutesGroup) Use ¶
func (g *RoutesGroup) Use(mds ...handler.Middleware)
Use add middleware to the group middleware will be called in the order of use Or call NewHandler to add a new middleware