Documentation
¶
Overview ¶
Package mux defines a simple API for all http multiplexers to implement.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Http ¶
type Http struct {
// contains filtered or unexported fields
}
Http wraps a http.ServeMux and provides some helpers around overriding the default "HTTP 404 Not Found" and "HTTP 405 Method Not Allowed" behaviour.
func NewHttp ¶
func NewHttp(opts ...HttpOption) *Http
NewHttp initializes a request multiplexer using the standard [http.ServeMux.]
func (*Http) Handle ¶
Handle will register the http.Handler for the given method and pattern with the underlying http.ServeMux. The method and pattern will be formatted together as "method pattern" when calling http.ServeMux.Handle.
func (*Http) ServeHTTP ¶
func (m *Http) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler interface.
type HttpOption ¶
type HttpOption func(*Http)
HttpOption defines a configuration option for Http.
func MethodNotAllowedHandler ¶
func MethodNotAllowedHandler(h http.Handler) HttpOption
MethodNotAllowedHandler will register the given http.Handler to handle any HTTP requests whose method does not match the method registered to a pattern.
func NotFoundHandler ¶
func NotFoundHandler(h http.Handler) HttpOption
NotFoundHandler will register the given http.Handler to handle any HTTP requests that do not match any other method-pattern combinations.