nirvash/lfo/middleware.go

18 lines
387 B
Go
Raw Normal View History

package lfo
import (
"context"
"net/http"
core "nilfm.cc/git/nirvash/archetype"
)
func WithAdapter(next http.Handler, adapter core.Adapter) http.Handler {
handlerFunc := func(w http.ResponseWriter, req *http.Request) {
*req = *req.WithContext(context.WithValue(req.Context(), "adapter", adapter))
next.ServeHTTP(w, req)
}
return http.HandlerFunc(handlerFunc)
}