fill request with header and cookie data

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-10-26 22:36:04 +03:00
parent 7a39d86018
commit 505c59ba75
11 changed files with 171 additions and 41 deletions

View File

@@ -5,7 +5,7 @@ import (
"fmt"
"net/http"
"github.com/unistack-org/micro/v3/server"
"go.unistack.org/micro/v3/server"
)
// SetError pass error to caller
@@ -125,3 +125,24 @@ type registerRPCHandlerKey struct{}
func RegisterRPCHandler(b bool) server.Option {
return server.SetOption(registerRPCHandlerKey{}, b)
}
type headerKey struct{}
type handlerOptions struct {
headers []string
cookies []string
}
type FillRequestOption func(*handlerOptions)
func Header(headers ...string) FillRequestOption {
return func(o *handlerOptions) {
o.headers = append(o.headers, headers...)
}
}
func Cookie(cookies ...string) FillRequestOption {
return func(o *handlerOptions) {
o.cookies = append(o.cookies, cookies...)
}
}