2019-06-03 20:44:43 +03:00
|
|
|
package resolver
|
|
|
|
|
2020-04-09 13:03:33 +03:00
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
2019-06-03 20:44:43 +03:00
|
|
|
// NewOptions returns new initialised options
|
|
|
|
func NewOptions(opts ...Option) Options {
|
|
|
|
var options Options
|
|
|
|
for _, o := range opts {
|
|
|
|
o(&options)
|
|
|
|
}
|
2020-04-09 13:03:33 +03:00
|
|
|
|
|
|
|
if options.Namespace == nil {
|
2020-05-19 20:17:17 +03:00
|
|
|
options.Namespace = StaticNamespace("go.micro")
|
2020-04-09 13:03:33 +03:00
|
|
|
}
|
|
|
|
|
2019-06-03 20:44:43 +03:00
|
|
|
return options
|
|
|
|
}
|
|
|
|
|
|
|
|
// WithHandler sets the handler being used
|
|
|
|
func WithHandler(h string) Option {
|
|
|
|
return func(o *Options) {
|
|
|
|
o.Handler = h
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-09 13:03:33 +03:00
|
|
|
// WithNamespace sets the function which determines the namespace for a request
|
|
|
|
func WithNamespace(n func(*http.Request) string) Option {
|
2019-06-03 20:44:43 +03:00
|
|
|
return func(o *Options) {
|
|
|
|
o.Namespace = n
|
|
|
|
}
|
|
|
|
}
|