router

package
v0.0.0-...-b7cfe9d Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 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

This section is empty.

Functions

func ExportRoutes

func ExportRoutes(filePath string, logger zerolog.Logger) error

ExportRoutes queries the database and writes routes to the specified file in JSONL format

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
	Logger                    zerolog.Logger
	RouteReloadInterval       time.Duration
	EnableContentStoreUpdates bool
}

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

	Logger zerolog.Logger
	// 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