Documentation
¶
Index ¶
- func GetValue(req *http.Request, key string) string
- type Mux
- func (m *Mux) Delete(path string, handler http.Handler)
- func (m *Mux) Get(path string, handler http.Handler)
- func (m *Mux) Handle(path string, handler http.Handler)
- func (m *Mux) HandleFunc(path string, handler http.HandlerFunc)
- func (m *Mux) HandleNotFound(rw http.ResponseWriter, req *http.Request)
- func (m *Mux) Head(path string, handler http.Handler)
- func (m *Mux) NotFound(handler http.HandlerFunc)
- func (m *Mux) Options(path string, handler http.Handler)
- func (m *Mux) Patch(path string, handler http.Handler)
- func (m *Mux) Post(path string, handler http.Handler)
- func (m *Mux) Put(path string, handler http.Handler)
- func (m *Mux) ServeHTTP(rw http.ResponseWriter, req *http.Request)
- type Pattern
- type Route
- type Token
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Mux ¶
type Mux struct { Routes map[string][]*Route Static map[string]*Route // contains filtered or unexported fields }
Mux have routes and a notFound handler Route: all the registred route notFound: 404 handler, default http.NotFound if not provided
func (*Mux) HandleFunc ¶
func (m *Mux) HandleFunc(path string, handler http.HandlerFunc)
HandleFunc is use to pass a func(http.ResponseWriter, *Http.Request) instead of http.Handler
func (*Mux) HandleNotFound ¶
func (m *Mux) HandleNotFound(rw http.ResponseWriter, req *http.Request)
Handle when a request does not match a registered handler.
func (*Mux) NotFound ¶
func (m *Mux) NotFound(handler http.HandlerFunc)
NotFound the mux custom 404 handler
type Pattern ¶
Pattern content the required information for the route Pattern Exist: check if a variable was declare on the route ID: the name of the variable Pos: postition of var in the route path Value: is the value of the request parameters
type Route ¶
type Route struct { Path string Size int Token Token Pattern Pattern Handler http.Handler Method string }
Route content the required information for a valid route Path: is the Route URL Size: is the length of the path Token: is the value of each part of the path, split by / Pattern: is content information about the route, if it's have a route variable handler: is the handler who handle this route Method: define HTTP method on the route