mirror of
https://hacklab.nilfm.cc/nirvash
synced 2024-10-22 14:01:49 +00:00
18 lines
387 B
Go
18 lines
387 B
Go
|
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)
|
||
|
}
|
||
|
|