MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / FillContext

Function FillContext

pkg/webmiddleware/fillcontext.go:24–37  ·  view source on GitHub ↗

FillContext returns a middleware that fills global context into a call context.

(fillers ...fillcontext.Filler)

Source from the content-addressed store, hash-verified

22
23// FillContext returns a middleware that fills global context into a call context.
24func FillContext(fillers ...fillcontext.Filler) MiddlewareFunc {
25 return func(next http.Handler) http.Handler {
26 if len(fillers) == 0 {
27 return next
28 }
29 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
30 ctx := r.Context()
31 for _, fill := range fillers {
32 ctx = fill(ctx)
33 }
34 next.ServeHTTP(w, r.WithContext(ctx))
35 })
36 }
37}

Callers 3

NewServerFunction · 0.92
NewFunction · 0.92
TestFillContextFunction · 0.85

Calls 2

ContextMethod · 0.65
ServeHTTPMethod · 0.45

Tested by 1

TestFillContextFunction · 0.68