package main import ( "context" "net/http" ) func ConfigMiddleWare(cfg *Config) func(http.Handler) http.Handler { return func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ctx := context.WithValue(r.Context(), configKey, cfg) next.ServeHTTP(w, r.WithContext(ctx)) }) } }