Documentation ¶
Overview ¶
Package methodr provides http.Handler compliant routing based on the request method.
Index ¶
- Variables
- type Mux
- func CONNECT(h http.Handler) *Mux
- func DEFAULT(h http.Handler) *Mux
- func DELETE(h http.Handler) *Mux
- func GET(h http.Handler) *Mux
- func HEAD(h http.Handler) *Mux
- func OPTIONS(h http.Handler) *Mux
- func PATCH(h http.Handler) *Mux
- func POST(h http.Handler) *Mux
- func PUT(h http.Handler) *Mux
- func TRACE(h http.Handler) *Mux
- func (m *Mux) CONNECT(h http.Handler) *Mux
- func (m *Mux) DEFAULT(h http.Handler) *Mux
- func (m *Mux) DELETE(h http.Handler) *Mux
- func (m *Mux) GET(h http.Handler) *Mux
- func (m *Mux) HEAD(h http.Handler) *Mux
- func (m *Mux) OPTIONS(h http.Handler) *Mux
- func (m *Mux) PATCH(h http.Handler) *Mux
- func (m *Mux) POST(h http.Handler) *Mux
- func (m *Mux) PUT(h http.Handler) *Mux
- func (m *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (m *Mux) TRACE(h http.Handler) *Mux
Constants ¶
This section is empty.
Variables ¶
var ( // Changeable global default handler in case of miss on routing table. Default: DefaultHandlerMethodNotAllowed DefaultHandler = DefaultHandlerMethodNotAllowed // Default handler returning http.StatusMethodNotAllowed DefaultHandlerMethodNotAllowed = http.HandlerFunc(defaultHandleMethodNotAllowed) )
Functions ¶
This section is empty.
Types ¶
type Mux ¶
type Mux struct { Get http.Handler Head http.Handler Post http.Handler Put http.Handler Delete http.Handler Trace http.Handler Options http.Handler Connect http.Handler Patch http.Handler Default http.Handler // Default handler in case of miss }
Routing table with handler for all methods
func GET ¶
GET sets the handler used for GET method requests. HEAD requests are delegated to GET if there's a GET handler available and no HEAD handler set.
func HEAD ¶
HEAD sets the handler used for HEAD method requests. HEAD requests are delegated to GET if there's a GET handler available and no HEAD handler set.
func (*Mux) GET ¶
GET sets the handler used for GET method requests. HEAD requests are delegated to GET if there's a GET handler available and no HEAD handler set.
func (*Mux) HEAD ¶
HEAD sets the handler used for HEAD method requests. HEAD requests are delegated to GET if there's a GET handler available and no HEAD handler set.
func (*Mux) ServeHTTP ¶
func (m *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP routes requests depending on method routing table. In case of a miss the custom DEFAULT handler is used, otherwise the global DefaultHandler. HEAD requests are delegated to GET if there's a GET handler available and no HEAD handler set.