router

package
v0.0.0-...-3831c58 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RouteTypePrefix = "prefix"
	RouteTypeExact  = "exact"
)
View Source
const (
	SegmentsModePreserve = "preserve"
	SegmentsModeIgnore   = "ignore"
)
View Source
const (
	HandlerTypeBackend  = "backend"
	HandlerTypeRedirect = "redirect"
	HandlerTypeGone     = "gone"
)

Variables

View Source
var EnableDebugOutput bool

Functions

func NewAPIHandler

func NewAPIHandler(rout *Router) (api http.Handler, err error)

func RegisterMetrics

func RegisterMetrics(r prometheus.Registerer)

RegisterMetrics registers Prometheus metrics from the router module and the modules that it directly depends on. To use the default (global) registry, pass prometheus.DefaultRegisterer.

func VersionInfo

func VersionInfo() (v string)

VersionInfo returns human-readable version information in a format suitable for concatenation with other messages.

Types

type Options

type Options struct {
	BackendConnTimeout   time.Duration
	BackendHeaderTimeout time.Duration
	LogFileName          string
	RouteReloadInterval  time.Duration
}

type PgxIface

type PgxIface interface {
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
}

type Route

type Route struct {
	IncomingPath *string
	RouteType    *string
	BackendID    *string
	RedirectTo   *string
	SegmentsMode *string
	SchemaName   *string
	Details      *string
}

type Router

type Router struct {
	ReloadChan chan bool
	// contains filtered or unexported fields
}

Router is a wrapper around an HTTP multiplexer (trie.Mux) which retrieves its routes from a postgres database.

func NewRouter

func NewRouter(o Options) (rt *Router, err error)

func (*Router) PeriodicRouteUpdates

func (rt *Router) PeriodicRouteUpdates()

func (*Router) ServeHTTP

func (rt *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP delegates responsibility for serving requests to the proxy mux instance for this router.

Jump to

Keyboard shortcuts

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