Documentation
¶
Overview ¶
main.go is the canonical reference for extending the batteries-included starter with your OWN module. It boots the full ten-module app via starterapp.Run and contributes one custom, tenant-scoped "widgets" module through starterapp.WithModules. The custom routes are mounted on the same mux as the built-ins, so they inherit the identity middleware, the anonymous-mutation gate, and the request-body cap. The module still owns authorization: every route below checks widgets:read or widgets:write, while attribution comes from the authenticated principal via portslib.RequestActor.
Run it, then:
SID=$(curl -s -X POST localhost:8080/api/v1/auth/sessions \
-d '{"tenant_id":"tenant_local","email":"operator@local.test","password":"local-development-only"}' | jq -r .id)
curl -s -X POST localhost:8080/api/v1/widgets -H "Authorization: Bearer $SID" -d '{"name":"gadget"}'
curl -s localhost:8080/api/v1/widgets -H "Authorization: Bearer $SID"
ADR: ADR-0017 (composition through dependency injection), ADR-0029 (file purpose declaration). Convention: C-14 (every Go file declares its purpose).