resolver

package
v1.6.6 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: MIT Imports: 2 Imported by: 1

Documentation

Overview

Package resolver resolves a http request to an endpoint

Index

Constants

This section is empty.

Variables

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

Functions

func StaticNamespace

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

StaticNamespace returns the same namespace for each request

Types

type Endpoint

type Endpoint struct {
	// 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
}

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(r *http.Request) string) Option

WithNamespace sets the function which determines the namespace for a request

type Options

type Options struct {
	Handler   string
	Namespace func(r *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

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 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