server: add server.SetHandlerOption helper
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
3ba8cb7f9e
commit
395a3eed3d
@ -42,3 +42,13 @@ func SetSubscriberOption(k, v interface{}) SubscriberOption {
|
||||
o.Context = context.WithValue(o.Context, k, v)
|
||||
}
|
||||
}
|
||||
|
||||
// SetHandlerOption returns a function to setup a context with given value
|
||||
func SetHandlerOption(k, v interface{}) HandlerOption {
|
||||
return func(o *HandlerOptions) {
|
||||
if o.Context == nil {
|
||||
o.Context = context.Background()
|
||||
}
|
||||
o.Context = context.WithValue(o.Context, k, v)
|
||||
}
|
||||
}
|
||||
|
@ -322,7 +322,7 @@ type HandlerOption func(*HandlerOptions)
|
||||
type HandlerOptions struct {
|
||||
// Context holds external options
|
||||
Context context.Context
|
||||
// Metadata for hondler
|
||||
// Metadata for handler
|
||||
Metadata map[string]metadata.Metadata
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user