resolver

package
v3.5.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package resolver resolves a http request to an endpoint

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound returned when endpoint is not found
	ErrNotFound = errors.New("not found")
	// ErrInvalidPath returned on invalid path
	ErrInvalidPath = errors.New("invalid path")
)

Functions

This section is empty.

Types

type Endpoint

type Endpoint struct {
	// Endpoint name e.g greeter
	Name string
	// HTTP Host e.g example.com
	Host string
	// HTTP Methods e.g GET, POST
	Method string
	// HTTP Path e.g /greeter.
	Path string
	// Domain endpoint exists within
	Domain string
}

Endpoint is the endpoint for a http request

type Option

type Option func(o *Options)

Option func

func WithHandler

func WithHandler(h string) Option

WithHandler sets the handler being used

func WithServicePrefix

func WithServicePrefix(p string) Option

WithServicePrefix sets the ServicePrefix option

type Options

type Options struct {
	// Context is for external defined options
	Context context.Context
	// Handler name
	Handler string
	// ServicePrefix is the prefix
	ServicePrefix string
}

Options struct

func NewOptions

func NewOptions(opts ...Option) Options

NewOptions returns new initialised options

type ResolveOption

type ResolveOption func(*ResolveOptions)

ResolveOption sets an option

func Domain

func Domain(n string) ResolveOption

Domain sets the resolve Domain option

type ResolveOptions

type ResolveOptions struct {
	Domain string
}

ResolveOptions are used when resolving a request

func NewResolveOptions

func NewResolveOptions(opts ...ResolveOption) ResolveOptions

NewResolveOptions returns new initialised resolve options

type Resolver

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

Resolver resolves requests to endpoints

Directories

Path Synopsis
Package grpc resolves a grpc service like /greeter.Say/Hello to greeter service
Package grpc resolves a grpc service like /greeter.Say/Hello to greeter service
Package host resolves using http host
Package host resolves using http host
Package path resolves using http path
Package path resolves using http path
Package subdomain is a resolver which uses the subdomain to determine the domain to route to.
Package subdomain is a resolver which uses the subdomain to determine the domain to route to.
Package vpath resolves using http path and recognised versioned urls
Package vpath resolves using http path and recognised versioned urls

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL