...
1
2
3
4 package grpc_ctxtags
5
6 var (
7 defaultOptions = &options{
8 requestFieldsFunc: nil,
9 }
10 )
11
12 type options struct {
13 requestFieldsFunc RequestFieldExtractorFunc
14 requestFieldsFromInitial bool
15 }
16
17 func evaluateOptions(opts []Option) *options {
18 optCopy := &options{}
19 *optCopy = *defaultOptions
20 for _, o := range opts {
21 o(optCopy)
22 }
23 return optCopy
24 }
25
26 type Option func(*options)
27
28
29
30 func WithFieldExtractor(f RequestFieldExtractorFunc) Option {
31 return func(o *options) {
32 o.requestFieldsFunc = f
33 }
34 }
35
36
37
38
39 func WithFieldExtractorForInitialReq(f RequestFieldExtractorFunc) Option {
40 return func(o *options) {
41 o.requestFieldsFunc = f
42 o.requestFieldsFromInitial = true
43 }
44 }
45
View as plain text