Package resolver resolves a http request to an endpoint



This section is empty.


View Source
var (
	ErrNotFound    = errors.New("not found")
	ErrInvalidPath = errors.New("invalid path")


func StaticNamespace

func StaticNamespace(ns string) func(*http.Request) string

StaticNamespace returns the same namespace for each request


type Endpoint

type Endpoint struct {
	// e.g greeter
	Name string
	// HTTP Host e.g
	Host string
	// HTTP Methods e.g GET, POST
	Method string
	// HTTP Path e.g /greeter.
	Path string

Endpoint is the endpoint for a http request

type Option

type Option func(o *Options)

func WithHandler

func WithHandler(h string) Option

WithHandler sets the handler being used

func WithNamespace

func WithNamespace(n func(*http.Request) string) Option

WithNamespace sets the function which determines the namespace for a request

type Options

type Options struct {
	Handler   string
	Namespace func(*http.Request) string

func NewOptions

func NewOptions(opts ...Option) Options

NewOptions returns new initialised options

type Resolver

type Resolver interface {
	Resolve(r *http.Request) (*Endpoint, error)
	String() string

Resolver resolves requests to endpoints


Path Synopsis
grpc Package grpc resolves a grpc service like /greeter.Say/Hello to greeter service
host Package host resolves using http host
path Package path resolves using http path
vpath Package vpath resolves using http path and recognised versioned urls