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

Function apiVersionCtx

_examples/versions/main.go:51–58  ·  view source on GitHub ↗
(version string)

Source from the content-addressed store, hash-verified

49}
50
51func apiVersionCtx(version string) func(next http.Handler) http.Handler {
52 return func(next http.Handler) http.Handler {
53 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
54 r = r.WithContext(context.WithValue(r.Context(), "api.version", version))
55 next.ServeHTTP(w, r)
56 })
57 }
58}
59
60func articleRouter() http.Handler {
61 r := chi.NewRouter()

Callers 1

mainFunction · 0.85

Calls 2

HandlerFuncMethod · 0.80
ServeHTTPMethod · 0.45

Tested by

no test coverage detected