// readme

Router

GOV.UK Router is an HTTP reverse proxy built on top of [triemux][tm].

How router loads routes

Router loads its routing table from Content Store’s PostgreSQL database (or optionally from a flat file) into a trie data structure for fast path lookups.

Router can reload routes without restarting:

  1. Automatically via PostgreSQL’s LISTEN/NOTIFY mechanism
  2. Periodic schedule
  3. Manually via the API server

Internally these use a Go channel to send reload requests that causes Router to reload from content-store's PostgreSQL database.

Routes

Routes can be one of two types:

  • exact: The path must match exactly (e.g. the exact route /government only matches a request for /government)
  • prefix: The path prefix must match (e.g. the prefix route /government matches requests for /government, /government/policies, etc.)

The route type and URL path determine which route gets matched to a particular request.

Router maintains two separate tries:

  1. Exact path matches
  2. Prefix matches

Once a request comes in, Router uses the URL path to first check for an exact match,…