Fix HTTP tests

This commit is contained in:
Ben Toogood
2020-04-09 10:28:38 +01:00
parent 8ff86ae08b
commit f102aba4c1
4 changed files with 36 additions and 14 deletions

View File

@@ -8,15 +8,18 @@ import (
"github.com/micro/go-micro/v2/api/resolver"
)
type Resolver struct{}
type Resolver struct {
opts resolver.Options
}
func (r *Resolver) Resolve(req *http.Request) (*resolver.Endpoint, error) {
if req.URL.Path == "/" {
return nil, resolver.ErrNotFound
}
parts := strings.Split(req.URL.Path[1:], "/")
return &resolver.Endpoint{
Name: parts[0],
Name: r.opts.Namespace + "." + parts[0],
Host: req.Host,
Method: req.Method,
Path: req.URL.Path,
@@ -28,5 +31,5 @@ func (r *Resolver) String() string {
}
func NewResolver(opts ...resolver.Option) resolver.Resolver {
return &Resolver{}
return &Resolver{opts: resolver.NewOptions(opts...)}
}