github.com/btccom/go-micro/v2@v2.9.3/api/resolver/resolver.go (about) 1 // Package resolver resolves a http request to an endpoint 2 package resolver 3 4 import ( 5 "errors" 6 "net/http" 7 ) 8 9 var ( 10 ErrNotFound = errors.New("not found") 11 ErrInvalidPath = errors.New("invalid path") 12 ) 13 14 // Resolver resolves requests to endpoints 15 type Resolver interface { 16 Resolve(r *http.Request) (*Endpoint, error) 17 String() string 18 } 19 20 // Endpoint is the endpoint for a http request 21 type Endpoint struct { 22 // e.g greeter 23 Name string 24 // HTTP Host e.g example.com 25 Host string 26 // HTTP Methods e.g GET, POST 27 Method string 28 // HTTP Path e.g /greeter. 29 Path string 30 } 31 32 type Options struct { 33 Handler string 34 Namespace func(*http.Request) string 35 } 36 37 type Option func(o *Options) 38 39 // StaticNamespace returns the same namespace for each request 40 func StaticNamespace(ns string) func(*http.Request) string { 41 return func(*http.Request) string { 42 return ns 43 } 44 }