Documentation ¶
Index ¶
- Constants
- Variables
- type App
- type Handle
- type Router
- func (r *Router) All(route string, handle Handle)
- func (r *Router) Delete(route string, handle Handle)
- func (r *Router) Get(route string, handle Handle)
- func (r *Router) Handle(method, route string, handle Handle)
- func (r *Router) Head(route string, handle Handle)
- func (r *Router) Options(route string, handle Handle)
- func (r *Router) Patch(route string, handle Handle)
- func (r *Router) Post(route string, handle Handle)
- func (r *Router) Put(route string, handle Handle)
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (r *Router) Use(middleware Handle)
- type TrailingSlashPolicy
Constants ¶
View Source
const ( // Enables automatic use similar route if the current route can't be // matched but a handle for the path with (without) the trailing slash exists. // For example if /foo/ is requested but a route only exists for /foo, // the handler for /foo will be used to handle /foo/ as well. TrailingSlashPolicyStatic = TrailingSlashPolicy(iota) // Enables automatic redirection if the current route can't be matched but a // handle for the path with (without) the trailing slash exists. // For example if /foo/ is requested but a route only exists for /foo, the // client is redirected to /foo with http status code 301. TrailingSlashPolicyRedirect // Disable automatic handle the trailing slash in URL. TrailingSlashPolicyNone HTTPMethodAll = "ALL" )
View Source
const DefaultDelimiter = "/"
Default configs.
Variables ¶
View Source
var PathRegexp = regexp2.MustCompile(strings.Join([]string{ "(\\\\.)", "(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?", }, "|"), regexp2.None)
The main path matching regexp utility.
Functions ¶
This section is empty.
Types ¶
type Router ¶
type Router struct { // How to handle the trailing slash in URL // TrailingSlashPolicyStatic (default) or TrailingSlashPolicyRedirect // or TrailingSlashPolicyNone TrailingSlashPolicy TrailingSlashPolicy // Function to handle panics recovered from http handlers. // It should be used to generate a error page and return the http error code // 500 (Internal Server Error). // The handle can be used to keep your server from crashing because of // unrecovered panics. PanicHandler func(http.ResponseWriter, *http.Request, interface{}) // contains filtered or unexported fields }
type TrailingSlashPolicy ¶
type TrailingSlashPolicy int
Click to show internal directories.
Click to hide internal directories.