A small Go service that serves the website at:
The service is built on top of the mvc package from go-service and ships as a single binary with server-side templates, content, the favicon, and static site assets embedded.
This project is an implementation playground for the ideas outlined in:
At a high level the service:
/)/books)robots.txt (/robots.txt)sitemap.xml (/sitemap.xml)/favicon.ico)The HTML templates, error templates, books YAML data, favicon image, robots file, and sitemap are embedded into the binary using go:embed. Full-page browser rendering loads HTMX and selected daisyUI 5.8.0 CSS components with the Silk theme from jsDelivr. All CDN resources are pinned with integrity hashes. Stylesheets are loaded individually to avoid combined CDN CSS source maps that DevTools would fetch outside the CSP’s connect-src allowlist. The full layout includes the site’s responsive styles; no frontend build step or additional JavaScript runtime is required.
The home page uses an editorial layout with system fonts, and the books page presents recommendations as responsive cards with localized “View book” links.
This repo follows the structure described in:
Key directories:
main.go: entrypoint for the web binaryinternal/: application code (not importable from other modules)test/: acceptance/system tests and supporting Ruby test clientbin/ + Makefile: build/dev/test automationThe service is wired with dependency injection using go-signal/v2. The top-level module that assembles the server is:
internal/cmd.ModuleIt pulls in configuration, health, and site modules.
Routing and rendering are handled using:
go-service/v3/net/http/mvcFeature modules (e.g. books/root/robots/sitemap) register their routes during DI wiring.
Full pages, partial renders, and not-found pages select English, German, or
Spanish from the request’s Accept-Language header. English is the default when
the header is absent, invalid, or unsupported. Regional preferences such as
de-CH and es-MX match the corresponding supported language.
curl -i -H 'Accept-Language: de' http://localhost:11000/books
curl -i -X PUT -H 'Accept-Language: es' http://localhost:11000/books
Localized HTML responses include Content-Language and Vary: Accept-Language;
full pages also set <html lang> to the selected language. Page metadata,
navigation, page text, book topics and recommendation notes, and the footer are
translated. Book titles, author names, links, and static assets retain their
original values.
Messages live in internal/site/locales/active.{en,de,es}.yaml and are embedded
in the binary. site.NewCatalog loads them during startup, so invalid catalogs
or message template syntax prevent startup. MVC supplies .Localizer to each
template; .Localizer.Text resolves message IDs, and .Localizer.Message
supplies variables such as the footer year and version. Missing translations
fall back to English. Missing message IDs or invalid message variables fail
rendering. Templates escape localized text as HTML.
The site package embeds:
internal/site/root/layout/site.cssrobots.txtsitemap.xmlSee:
internal/site/site.goGET / renders the home pagePUT / renders a partial/fragment version of the home page (used for incremental updates)GET /books renders the books pagePUT /books renders a partial/fragment version of the books pageGET /robots.txt serves the robots file as a static assetGET /sitemap.xml serves the sitemap file as a static assetGET /favicon.ico serves the browser faviconGET /assets/site.css serves the embedded stylesheet404 not-found page[!NOTE] The
PUTendpoints exist to support partial rendering patterns, for example HTMX-style incremental updates. The exact response shape depends on the templates/layout configured in the MVC layer.
[!TIP] Use
GETwhen checking complete pages in a browser andPUTwhen checking fragment rendering.
The HTTP transport registers service-prefixed health and observability routes.
With the local service name web, the endpoints are:
/web/healthz (overall health / online)/web/livez (liveness)/web/readyz (readiness)/web/metrics (Prometheus metrics)Health timings are configured via the service config under the health section.
/web/metrics is registered only when metrics are enabled with
telemetry.metrics.kind: prometheus, as in the local config. Disabled or OTLP
metrics do not expose that route.
/web/healthz uses the default go-health/v2 online registration. It checks
https://google.com/generate_204, https://cp.cloudflare.com/generate_204, and
https://connectivity-check.ubuntu.com concurrently, and reports healthy when
any one responds with 200 OK or 204 No Content. Restricted public
connectivity can therefore affect overall health. /web/livez and
/web/readyz use noop checks.
Site responses include browser security headers such as Content-Security-Policy, X-Content-Type-Options, Referrer-Policy, X-Frame-Options, Permissions-Policy, and Strict-Transport-Security.
The CSP permits the site’s own stylesheet, jsDelivr for HTMX and daisyUI CSS,
and Cloudflare Insights script and beacon origins (static.cloudflareinsights.com
and cloudflareinsights.com) for production browser analytics.
The static routes /robots.txt, /sitemap.xml, and /favicon.ico return
Cache-Control: public, max-age=3600. Clients can reuse the response for one
hour. The MVC handler serves the full asset on each successful GET request.
MVC applies the same cache policy to /assets/site.css. Full pages link to the
stylesheet with its SHA-256 fingerprint in the v query parameter. A mismatch
returns 404 with Cache-Control: no-store. During a rolling deployment, every
replica that can receive a stylesheet request needs to serve the fingerprint
linked by the page.
[!NOTE] The acceptance suite verifies security headers across page, static-asset, and not-found responses. It also checks the static cache policy and follows the fingerprinted stylesheet link advertised by the page.
Install:
go.mod; check locally with go version)gmake on macOS when /usr/bin/make is incompatible)If you are cloning the repo, initialize submodules before relying on Make targets:
[!IMPORTANT] The required
binsubmodule uses a GitHub SSH URL. Configure GitHub SSH access before running the recursive clone or submodule update commands.
git clone --recurse-submodules https://github.com/alexfalkowski/web.git
For an existing checkout where bin/ may be absent or stale:
git submodule sync
git submodule update --init
Then install dependencies:
make dep
[!IMPORTANT] The root
Makefileincludes shared build fragments frombin/, so a missing submodule can preventmakefrom parsing at all. Oncebin/is present,make submodulecan refresh it through the normal repo target.
[!WARNING] Some targets require external tools in addition to Go and Ruby. For example,
make devusesair, Go checks may usegotestsum,golangci-lint, andgovulncheck, and security checks may use Trivy.
This repo relies on make for a consistent developer experience.
List all available commands:
make help
Common workflows:
# Install dependencies (Go + Ruby)
make dep
# Run linters
make lint
# Auto-fix lint where possible
make fix-lint
# Format code
make format
# Run the repo-defined Go specs wrapper
make specs
# Run Cucumber acceptance tests
make features
# Run Cucumber benchmark scenarios
make benchmarks
[!TIP]
make helpis the best way to discover the current command surface because most project workflows come from the sharedbin/Make fragments.
There are two common ways to run the service:
Use the dev target (recommended while iterating):
make dev
This runs the service with test/.config/server.yaml.
Build a local binary:
make build
Then run it:
./web server -config file:test/.config/server.yaml
[!IMPORTANT] The current config flag is
-config;-cis the short form. The CLI command isserver, registered ininternal/cmd, and starts the HTTP server using the DI module graph.
Once the server is running, you can verify key endpoints.
If you started the service with make dev or with -config file:test/.config/server.yaml,
the HTTP server listens on localhost:11000.
Pages:
curl -i http://localhost:11000/
curl -i http://localhost:11000/books
curl -i http://localhost:11000/robots.txt
curl -i http://localhost:11000/sitemap.xml
curl -i http://localhost:11000/favicon.ico
Partial renders (PUT):
curl -i -X PUT http://localhost:11000/
curl -i -X PUT http://localhost:11000/books
Health:
curl -i http://localhost:11000/web/healthz
curl -i http://localhost:11000/web/livez
curl -i http://localhost:11000/web/readyz
curl -i http://localhost:11000/web/metrics
Not found:
curl -i http://localhost:11000/not-a-real-page
[!CAUTION] Ports, TLS, telemetry, and other server settings come from configuration. Do not treat
test/.config/server.yamlas a production configuration.
The service config model lives in:
internal/config.ConfigIt embeds the shared base config from go-service and adds a health section.
The canonical local example is:
test/.config/server.yamlThe -config flag (short form -c) accepts these source routes:
file:<path> loads a file and selects its decoder from the extension.env:<ENV_VAR> loads an environment variable whose value has the form
<extension>:<base64-content> (for example, yaml:...).web.{yaml,yml,hjson,toml,json} in the executable directory, the user config
directory under web/, and /etc/web/. This lookup requires HOME or
XDG_CONFIG_HOME; use an explicit source when neither is available.The local development config in test/.config/server.yaml includes this
first-use excerpt:
health:
duration: 1s
timeout: 1s
transport:
http:
address: tcp://:11000
The service-specific health section is required. health.duration must be a
positive Go duration and controls how often health registrations are evaluated;
health.timeout may be zero or greater and controls the online health check
timeout. A zero timeout selects the go-health/v2 default of 30 seconds.
[!NOTE] The full local config also sets the environment, UUID generation, tint logging, Prometheus metrics, an OTLP tracer endpoint, HTTP limiter tokens/interval, and HTTP timeout. The wider configuration shape comes from shared
go-servicesections such as environment, telemetry, transport, and version metadata.
The primary behavioral checks are the Ruby/Cucumber suites:
make features
make benchmarks
These targets run the acceptance harness from test/. Nonnative loads
test/nonnative.yml, starts ../web server -config file:.config/server.yaml on
localhost:11000, and writes Nonnative, server, and Cucumber output under
test/reports/. Stop any local service already using 11000 before running the
acceptance suites.
To run a narrower acceptance scope while iterating, pass feature paths relative
to test/:
make features feature=features/site/site.feature
make features feature=features/health/observability.feature
make benchmarks feature=features/site/benchmark.feature
The main CircleCI service build also runs:
make lint
make sec
make analyse
make coverage
make codecov-upload
make codecov-upload is CI upload behavior, not a read-only local validation
step.
The full CircleCI workflow additionally runs Docker image checks and the
submodule sync/push job on non-master branches:
make platform=amd64 test-docker
make platform=arm64 test-docker
make sync push
On master, CircleCI also runs versioning, Docker release/manifest, and deploy jobs.
Go support checks are still available:
make specs
go test ./...
[!NOTE] Treat
make featuresandmake benchmarksas the authoritative product behavior checks. The Go tests support build/tooling confidence but are not the main product signal.
The Ruby test helper client is in:
test/lib/web.rbtest/lib/web/v1/http.rbIt provides a small wrapper around HTTP calls used by the acceptance tests.
Go code generally follows:
Releases are handled through CI and GoReleaser configuration:
.circleci/config.yml.goreleaser.ymlGenerated changelog text is part of the GoReleaser release flow.
[!CAUTION] Release, Docker publishing, deployment, and GitHub PR targets can push to external systems. Use the read-only validation targets unless you intend to publish or update remote state.
See:
LICENSE