Documentation
¶
Index ¶
Constants ¶
const ( RouteTypePrefix = "prefix" RouteTypeExact = "exact" )
const ( SegmentsModePreserve = "preserve" SegmentsModeIgnore = "ignore" )
const ( HandlerTypeBackend = "backend" HandlerTypeRedirect = "redirect" HandlerTypeGone = "gone" )
Variables ¶
This section is empty.
Functions ¶
func ExportRoutes ¶
ExportRoutes queries the database and writes routes to the specified file in JSONL format
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
}
Additional configurable options
type Route ¶
type Route struct {
IncomingPath *string
RouteType *string
BackendID *string
RedirectTo *string
SegmentsMode *string
SchemaName *string
Details *string
}
IncomingPath is the URL path of the route (e.g. /foo) RouteType is the type of matching the route should do (exact/prefix) BackendID is the backend application (e.g. frontend, publisher etc...) RedirectTo is the redirect location for a redirect route SegmentsMode indicates whether the URL path for a redirect route should be preserved (preserve/ignore) SchemaName indicates the type of route (backend, redirect, gone) Details contains additional information about the route
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 (content-store)
func NewRouter ¶
Creates an instance of Router struct which: 1. Loads routes from file or content-store database 2. Sets up a channel that will be used to send reload requests 3. If enabled starts goroutine to listen for content-store updates 4. Starts goroutine to listen for reload requests
func (*Router) PeriodicRouteUpdates ¶
func (rt *Router) PeriodicRouteUpdates()
Periodically send boolean messages (true) to Router's channel that signals it to reload routes from content-store's database.