github.com/btccom/go-micro/v2@v2.9.3/api/resolver/options.go (about)

     1  package resolver
     2  
     3  import (
     4  	"net/http"
     5  )
     6  
     7  // NewOptions returns new initialised options
     8  func NewOptions(opts ...Option) Options {
     9  	var options Options
    10  	for _, o := range opts {
    11  		o(&options)
    12  	}
    13  
    14  	if options.Namespace == nil {
    15  		options.Namespace = StaticNamespace("go.micro")
    16  	}
    17  
    18  	return options
    19  }
    20  
    21  // WithHandler sets the handler being used
    22  func WithHandler(h string) Option {
    23  	return func(o *Options) {
    24  		o.Handler = h
    25  	}
    26  }
    27  
    28  // WithNamespace sets the function which determines the namespace for a request
    29  func WithNamespace(n func(*http.Request) string) Option {
    30  	return func(o *Options) {
    31  		o.Namespace = n
    32  	}
    33  }