forked from pydio/cells
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
40 lines (33 loc) · 788 Bytes
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package router
import (
"github.com/micro/go-api"
microrouter "github.com/micro/go-api/router"
"github.com/micro/go-micro/cmd"
"github.com/micro/go-micro/registry"
)
func newOptions(opts ...microrouter.Option) microrouter.Options {
options := microrouter.Options{
Namespace: "go.micro.api",
Handler: api.Default,
Registry: *cmd.DefaultOptions().Registry,
}
for _, o := range opts {
o(&options)
}
return options
}
func WithHandler(h api.Handler) microrouter.Option {
return func(o *microrouter.Options) {
o.Handler = h
}
}
func WithNamespace(ns string) microrouter.Option {
return func(o *microrouter.Options) {
o.Namespace = ns
}
}
func WithRegistry(r registry.Registry) microrouter.Option {
return func(o *microrouter.Options) {
o.Registry = r
}
}