Documentation
¶
Index ¶
- func Context(r *http.Request) context.Context
- func FileServe(dir string) http.HandlerFunc
- func Param(ctx context.Context, p string) string
- func WithParam(ctx context.Context, p, v string) context.Context
- type Router
- func (r *Router) Del(path string, h http.HandlerFunc)
- func (r *Router) Get(path string, h http.HandlerFunc)
- func (r *Router) Post(path string, h http.HandlerFunc)
- func (r *Router) Put(path string, h http.HandlerFunc)
- func (r *Router) Redirect(w http.ResponseWriter, req *http.Request, path string, code int)
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (r *Router) WithPrefix(prefix string) *Router
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Context ¶
Context returns the context for the request.
func FileServe ¶
func FileServe(dir string) http.HandlerFunc
FileServe returns a new http.HandlerFunc that serves files from dir. Using routes must provide the *filepath parameter.
func Param ¶
Param returns param p for the context.
Types ¶
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router wraps httprouter.Router and adds support for prefixed sub-routers.
func (*Router) Del ¶
func (r *Router) Del(path string, h http.HandlerFunc)
Del registers a new DELETE route.
func (*Router) Get ¶
func (r *Router) Get(path string, h http.HandlerFunc)
Get registers a new GET route.
func (*Router) Post ¶
func (r *Router) Post(path string, h http.HandlerFunc)
Post registers a new POST route.
func (*Router) Put ¶
func (r *Router) Put(path string, h http.HandlerFunc)
Put registers a new PUT route.
func (*Router) Redirect ¶
Redirect takes an absolute path and sends an internal HTTP redirect for it, prefixed by the router's path prefix. Note that this method does not include functionality for handling relative paths or full URL redirects.
Source Files
¶
- route.go
Click to show internal directories.
Click to hide internal directories.