github.com/micro/go-micro/v2@v2.9.1/proxy/options.go (about) 1 // Package proxy is a transparent proxy built on the go-micro/server 2 package proxy 3 4 import ( 5 "github.com/micro/go-micro/v2/client" 6 "github.com/micro/go-micro/v2/router" 7 ) 8 9 type Options struct { 10 // Specific endpoint to always call 11 Endpoint string 12 // The default client to use 13 Client client.Client 14 // The default router to use 15 Router router.Router 16 // Extra links for different clients 17 Links map[string]client.Client 18 } 19 20 type Option func(o *Options) 21 22 // WithEndpoint sets a proxy endpoint 23 func WithEndpoint(e string) Option { 24 return func(o *Options) { 25 o.Endpoint = e 26 } 27 } 28 29 // WithClient sets the client 30 func WithClient(c client.Client) Option { 31 return func(o *Options) { 32 o.Client = c 33 } 34 } 35 36 // WithRouter specifies the router to use 37 func WithRouter(r router.Router) Option { 38 return func(o *Options) { 39 o.Router = r 40 } 41 } 42 43 // WithLink sets a link for outbound requests 44 func WithLink(name string, c client.Client) Option { 45 return func(o *Options) { 46 if o.Links == nil { 47 o.Links = make(map[string]client.Client) 48 } 49 o.Links[name] = c 50 } 51 }