Documentation
¶
Overview ¶
Package servemux implements an API-compatible http.ServeMux alternative that uses Varouter internally. It serves mostly as an example of how to wrap Varouter into a custom mux.
Index ¶
- func Placeholders(r *http.Request) varouter.Vars
- type ServeMux
- func (mux *ServeMux) Handle(pattern string, handler http.Handler)
- func (mux *ServeMux) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
- func (mux *ServeMux) Handler(r *http.Request) (h http.Handler, pattern string)
- func (mux *ServeMux) ServeHTTP(w http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ServeMux ¶
type ServeMux struct {
// contains filtered or unexported fields
}
ServeMux is a serve mux that is API identical to http.ServeMux but is using varouter internally. The behaviour also mirrors Varouter's behaviour.
Additionally, it stores any parsed Placeholders in a Placeholder map in the request context which is accessible via Placeholders helper function.
func (*ServeMux) Handle ¶
Handle registers the handler for the given pattern. If a handler already exists for pattern, Handle panics.
func (*ServeMux) HandleFunc ¶
HandleFunc registers the handler function for the given pattern.
Click to show internal directories.
Click to hide internal directories.