github.com/annwntech/go-micro/v2@v2.9.5/api/resolver/host/host.go (about) 1 // Package host resolves using http host 2 package host 3 4 import ( 5 "net/http" 6 7 "github.com/annwntech/go-micro/v2/api/resolver" 8 ) 9 10 type Resolver struct { 11 opts resolver.Options 12 } 13 14 func (r *Resolver) Resolve(req *http.Request, opts ...resolver.ResolveOption) (*resolver.Endpoint, error) { 15 // parse options 16 options := resolver.NewResolveOptions(opts...) 17 return &resolver.Endpoint{ 18 Name: req.Host, 19 Host: req.Host, 20 Method: req.Method, 21 Path: req.URL.Path, 22 Domain: options.Domain, 23 }, nil 24 } 25 26 func (r *Resolver) String() string { 27 return "host" 28 } 29 30 func NewResolver(opts ...resolver.Option) resolver.Resolver { 31 return &Resolver{opts: resolver.NewOptions(opts...)} 32 }