Documentation ¶
Index ¶
- type Group
- type Router
- func (r *Router) ANY(path string, handler types.RequestHandler)
- func (r *Router) CONNECT(path string, handler types.RequestHandler)
- func (r *Router) DELETE(path string, handler types.RequestHandler)
- func (r *Router) GET(path string, handler types.RequestHandler)
- func (r *Router) Group(path string) *Group
- func (r *Router) HEAD(path string, handler types.RequestHandler)
- func (r *Router) Handle(method, path string, handler types.RequestHandler)
- func (r *Router) Handler(ctx *fasthttp.RequestCtx)
- func (r *Router) List() map[string][]string
- func (r *Router) Lookup(method, path string, ctx *fasthttp.RequestCtx) (fasthttp.RequestHandler, bool)
- func (r *Router) Mutable(v bool)
- func (r *Router) OPTIONS(path string, handler types.RequestHandler)
- func (r *Router) PATCH(path string, handler types.RequestHandler)
- func (r *Router) POST(path string, handler types.RequestHandler)
- func (r *Router) PUT(path string, handler types.RequestHandler)
- func (r *Router) ServeFiles(path string, rootPath string)
- func (r *Router) ServeFilesCustom(path string, fs *fasthttp.FS)
- func (r *Router) TRACE(path string, handler types.RequestHandler)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) ANY ¶
func (r *Router) ANY(path string, handler types.RequestHandler)
ANY is a shortcut for router.Handle(router.MethodWild, path, handler)
WARNING: Use only for routes where the request method is not important
func (*Router) CONNECT ¶
func (r *Router) CONNECT(path string, handler types.RequestHandler)
CONNECT is a shortcut for router.Handle(fasthttp.MethodConnect, path, handler)
func (*Router) DELETE ¶
func (r *Router) DELETE(path string, handler types.RequestHandler)
DELETE is a shortcut for router.Handle(fasthttp.MethodDelete, path, handler)
func (*Router) GET ¶
func (r *Router) GET(path string, handler types.RequestHandler)
GET is a shortcut for router.Handle(fasthttp.MethodGet, path, handler)
func (*Router) HEAD ¶
func (r *Router) HEAD(path string, handler types.RequestHandler)
HEAD is a shortcut for router.Handle(fasthttp.MethodHead, path, handler)
func (*Router) Handle ¶
func (r *Router) Handle(method, path string, handler types.RequestHandler)
Handle registers a new request handler with the given path and method.
For GET, POST, PUT, PATCH and DELETE requests the respective shortcut functions can be used.
This function is intended for bulk loading and to allow the usage of less frequently used, non-standardized or custom methods (e.g. for internal communication with a proxy).
func (*Router) Handler ¶
func (r *Router) Handler(ctx *fasthttp.RequestCtx)
Handler makes the router implement the http.Handler interface.
func (*Router) Lookup ¶
func (r *Router) Lookup(method, path string, ctx *fasthttp.RequestCtx) (fasthttp.RequestHandler, bool)
Lookup allows the manual lookup of a method + path combo. This is e.g. useful to build a framework around this router. If the path was found, it returns the handler function. Otherwise the second return value indicates whether a redirection to the same path with an extra / without the trailing slash should be performed.
func (*Router) OPTIONS ¶
func (r *Router) OPTIONS(path string, handler types.RequestHandler)
OPTIONS is a shortcut for router.Handle(fasthttp.MethodOptions, path, handler)
func (*Router) PATCH ¶
func (r *Router) PATCH(path string, handler types.RequestHandler)
PATCH is a shortcut for router.Handle(fasthttp.MethodPatch, path, handler)
func (*Router) POST ¶
func (r *Router) POST(path string, handler types.RequestHandler)
POST is a shortcut for router.Handle(fasthttp.MethodPost, path, handler)
func (*Router) PUT ¶
func (r *Router) PUT(path string, handler types.RequestHandler)
PUT is a shortcut for router.Handle(fasthttp.MethodPut, path, handler)
func (*Router) ServeFiles ¶
ServeFiles serves files from the given file system root. The path must end with "/{filepath:*}", files are then served from the local path /defined/root/dir/{filepath:*}. For example if root is "/etc" and {filepath:*} is "passwd", the local file "/etc/passwd" would be served. Internally a fasthttp.FSHandler is used, therefore fasthttp.NotFound is used instead Use:
router.ServeFiles("/src/{filepath:*}", "./")
func (*Router) ServeFilesCustom ¶
ServeFilesCustom serves files from the given file system settings. The path must end with "/{filepath:*}", files are then served from the local path /defined/root/dir/{filepath:*}. For example if root is "/etc" and {filepath:*} is "passwd", the local file "/etc/passwd" would be served. Internally a fasthttp.FSHandler is used, therefore http.NotFound is used instead of the Router's NotFound handler. Use:
router.ServeFilesCustom("/src/{filepath:*}", *customFS)