MCPcopy
hub / github.com/go-chi/chi / ServeHTTP

Method ServeHTTP

_examples/custom-handler/main.go:12–18  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

10type Handler func(w http.ResponseWriter, r *http.Request) error
11
12func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
13 if err := h(w, r); err != nil {
14 // handle returned error here.
15 w.WriteHeader(503)
16 w.Write([]byte("bad"))
17 }
18}
19
20func main() {
21 r := chi.NewRouter()

Callers 6

apiVersionCtxFunction · 0.45
randomErrorMiddlewareFunction · 0.45
ArticleCtxFunction · 0.45
AdminOnlyFunction · 0.45
paginateFunction · 0.45
FileServerFunction · 0.45

Calls 2

WriteMethod · 0.65
WriteHeaderMethod · 0.45

Tested by

no test coverage detected