router

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2021 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderUser = "X-User"
)

Variables

View Source
var ErrAbort = errors.New("abort")
View Source
var ErrSigningMethodUnsupported = errors.New("signing method unsupported")

Functions

This section is empty.

Types

type Config added in v0.0.2

type Config struct {
	PathRouting bool // path based routing instead of domains
	Port        int  // binding port, used only for index page
	Index       bool // show index in case of not found domain
}

type JWTClaims added in v0.0.2

type JWTClaims struct {
	jwt.StandardClaims
	Methods []string `json:"methods,omitempty"`
}

JWTClaims defined extended JWT claims schema.

type Random added in v0.0.2

type Random struct {
	// contains filtered or unexported fields
}

Random distribution to backend nodes. Based on service addresses.

func (*Random) ServeRoute added in v0.0.2

func (rnd *Random) ServeRoute(writer http.ResponseWriter, request *http.Request, route *Route) error

type Route added in v0.0.2

type Route struct {
	Group   string
	Service packs.Service
}

type RouteHandler added in v0.0.2

type RouteHandler interface {
	ServeRoute(writer http.ResponseWriter, request *http.Request, route *Route) error
}

func JWT added in v0.0.2

func JWT(sharedKey string) RouteHandler

JWT based authorization and authentication per-group (repo). subject is defining restriction for allowed group, methods for allowed HTTP methods. Sets HeaderUser to the request object in case of success.

type RouteHandlerFunc added in v0.0.2

type RouteHandlerFunc func(writer http.ResponseWriter, request *http.Request, route *Route) error

func (RouteHandlerFunc) ServeRoute added in v0.0.2

func (rhf RouteHandlerFunc) ServeRoute(writer http.ResponseWriter, request *http.Request, route *Route) error

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router for incoming request. Detects service by domain or path.

func New added in v0.0.2

func New(cfg Config) *Router

func (*Router) Handle added in v0.0.2

func (ed *Router) Handle(handler RouteHandler)

Handle routed request. Thread UNSAFE.

func (*Router) HasDomain added in v0.0.2

func (ed *Router) HasDomain(domain string) bool

HasDomain reports true in case domain is registered in the router. Thread safe.

func (*Router) ServeHTTP added in v0.0.2

func (ed *Router) ServeHTTP(writer http.ResponseWriter, request *http.Request)

func (*Router) ServeRoute added in v0.0.2

func (ed *Router) ServeRoute(writer http.ResponseWriter, request *http.Request, route *Route) error

func (*Router) Update

func (ed *Router) Update(group string, services []packs.Service)

Update routing table for services in group.

Jump to

Keyboard shortcuts

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