router

package
v1.1.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2025 License: Apache-2.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(serviceSelector selector.Selector, policySelectorCfg *config.PolicySelector, policies []config.Policy, logger log.Logger) func(http.Handler) http.Handler

Middleware returns a HTTP middleware containing the router.

func SetRoutingInfo

func SetRoutingInfo(parent context.Context, ri RoutingInfo) context.Context

SetRoutingInfo puts the routing info in the context.

Types

type Router

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

Router handles the routing of HTTP requests according to the given policies.

func New

func New(serviceSelector selector.Selector, policySelectorCfg *config.PolicySelector, policies []config.Policy, logger log.Logger) Router

New creates a new request router. It initializes the routes before returning the router.

func (Router) Route

func (rt Router) Route(r *http.Request) (RoutingInfo, bool)

Route is evaluating the policies on the request and returns the RoutingInfo if successful.

type RoutingInfo

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

RoutingInfo contains the proxy rewrite hook and some information about the route.

func ContextRoutingInfo

func ContextRoutingInfo(ctx context.Context) RoutingInfo

ContextRoutingInfo gets the routing information from the context.

func (RoutingInfo) IsRouteUnprotected

func (r RoutingInfo) IsRouteUnprotected() bool

IsRouteUnprotected returns true if the route doesn't need to be authenticated.

func (RoutingInfo) Rewrite

func (r RoutingInfo) Rewrite() func(*httputil.ProxyRequest)

Rewrite returns the proxy rewrite hook.

Jump to

Keyboard shortcuts

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