Minimal demo of foomo/gateway routing — no Docker, no Kubernetes required.
go run main.goEverything runs in a single process:
| Service | Role |
|---|---|
| Mock contentserver | Resolves URIs to mime types |
| Page frontend | Handles application/x-sandbox-page |
| News frontend | Handles application/x-sandbox-news |
| Error frontend | Handles 404 / 500 (errorFrontend: true) |
# known page URI
curl -i http://localhost:8080/
# another page
curl -i http://localhost:8080/about
# news article (different mime type → different frontend)
curl -i http://localhost:8080/news/article-1
# unknown URI → routed to error frontend
curl -i http://localhost:8080/missing
# built-in gateway endpoints
curl -i http://localhost:8080/robots.txt
curl -i http://localhost:8080/sitemap.xml
curl -i http://localhost:8080/gateway/statusX-Content-IdandX-Mime-Typeheaders are set on the proxied request — the frontend reads them to fetch page payload and site context in parallel.X-Error-Codeis set when routing to the error frontend./sitemap.xml,/robots.txt, and/gateway/statusare handled by the gateway itself.
The mock contentserver (contentTree in main.go) defines the known URIs and their mime types. Edit it to try
different routing scenarios.
In a real project the contentserver is a separate service loaded from your CMS. The gateway is unaware of mime type values — it routes whatever string the contentserver returns.