github.com/btccom/go-micro/v2@v2.9.3/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/btccom/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) (*resolver.Endpoint, error) {
    15  	return &resolver.Endpoint{
    16  		Name:   req.Host,
    17  		Host:   req.Host,
    18  		Method: req.Method,
    19  		Path:   req.URL.Path,
    20  	}, nil
    21  }
    22  
    23  func (r *Resolver) String() string {
    24  	return "host"
    25  }
    26  
    27  func NewResolver(opts ...resolver.Option) resolver.Resolver {
    28  	return &Resolver{opts: resolver.NewOptions(opts...)}
    29  }