(w http.ResponseWriter, r *http.Request)
| 32 | } |
| 33 | |
| 34 | func (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 | |
| 46 | func Example_middleware() { |
| 47 | server := NewServer() |