MCPcopy Create free account
hub / github.com/DoNewsCode/core / ServeHTTP

Method ServeHTTP

ctxmeta/example_middleware_test.go:34–44  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

32}
33
34func (mw *Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request) {
35 bag, ctx := ctxmeta.Inject(r.Context())
36
37 defer func() {
38 for _, kv := range bag.Slice() {
39 fmt.Printf("%s: %v\n", kv.Key, kv.Val)
40 }
41 }()
42
43 mw.next.ServeHTTP(w, r.WithContext(ctx))
44}
45
46func Example_middleware() {
47 server := NewServer()

Callers

nothing calls this directly

Calls 4

InjectFunction · 0.92
SliceMethod · 0.80
PrintfMethod · 0.45
ServeHTTPMethod · 0.45

Tested by

no test coverage detected