Skip to main content

Application: router

Router in front on GOV.UK to proxy to backend servers on the single domain

GitHub
router
Ownership
#govuk-platform-health
Hosting
AWS, on the cache machine class
Rake tasks
Integration, Staging or ⚠️ Production ⚠️

Imported documents

README

This is a HTTP reverse proxy router built on top of triemux. It loads a routing table into memory from a MongoDB database and acts as a:

  • Reverse proxy, forwarding requests to and serving responses from multiple backend servers on a single domain.
  • Redirector, serving HTTP 301 and 302 redirects to new URLs.
  • Gone responder, serving HTTP 410 responses for resources that used to but no longer exist.

The sister project router-api provides a read/write interface to the underlying database and route reloading.

Technical documentation

Recommended reading: How to Write Go Code

You can use the GOV.UK Docker environment to run the application and its tests with all the necessary dependencies. Follow the usage instructions to get started.

Use GOV.UK Docker to run any commands that follow.

Running the test suite

You can run all tests by running:

make test

The trie and triemux sub-packages have unit tests and benchmarks written in Go’s own testing framework. To run them individually:

go test -bench=. ./trie ./triemux

The router itself doesn’t really benefit from having unit tests around individual functions. Instead it has a comprehensive set of integration tests to exercise it’s HTTP handling, error reporting, and performance.

go test ./integration_tests

Updating dependencies

This project uses Go Modules to vendor its dependencies. To update the dependencies:

go mod vendor

Further documentation

License

MIT Licence