allow to use http middlewares
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
13
options.go
13
options.go
@@ -1,6 +1,11 @@
|
||||
package http
|
||||
|
||||
import "context"
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/unistack-org/micro/v3/server"
|
||||
)
|
||||
|
||||
type rspCodeKey struct{}
|
||||
type rspCodeVal struct {
|
||||
@@ -22,3 +27,9 @@ func GetRspCode(ctx context.Context) int {
|
||||
}
|
||||
return code
|
||||
}
|
||||
|
||||
type middlewareKey struct{}
|
||||
|
||||
func Middleware(mw ...func(http.Handler) http.Handler) server.Option {
|
||||
return server.SetOption(middlewareKey{}, mw)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user