Documentation
¶
Overview ¶
Package mux implements an HTTP multiplexer/router
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
Mux ...
func (*Mux) ServeHTTP ¶
func (mux *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP
func (mux *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request) {
var slash bool
p := r.URL.Path
for {
m, ok := mux.m[p]
if !ok {
if p != "/" {
p = cut(p, slash)
slash = !slash
continue
}
mux.handleError(w, http.StatusNotFound)
return
}
h, ok := m[r.Method]
if !ok {
mux.handleError(w, http.StatusMethodNotAllowed)
return
}
h.Handler.ServeHTTP(w, r)
return
}
}
Click to show internal directories.
Click to hide internal directories.