1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-01-05 10:20:53 +02:00
go-micro/api/resolver/options.go

33 lines
571 B
Go
Raw Normal View History

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