Skip to content

Port the service skeleton from standalone: config, logger, errors, gin router, container (T16) - #20

Merged
RyazanovAlexander merged 3 commits into
mainfrom
t16-service-skeleton
Oct 16, 2026
Merged

RyazanovAlexander merged 3 commits into
mainfrom
t16-service-skeleton

Conversation

@RyazanovAlexander

Copy link
Copy Markdown
Contributor
  • cmd/server: signals, errgroup, one report per failure, a stop during the start exits 0; the port is bound before the startup line.
  • internal/config: viper over declared CANVAS_* variables only; CANVAS_ENV local by default and prod-only where K_SERVICE is set; the shutdown budget shared between drain and close.
  • internal/logger, internal/apierror: Cloud Run keys; flat {code, message} with optional details.
  • internal/transport/http: gin router, /health on GET and HEAD, 404 and 405 as apierror, LastResort, SecurityHeaders, RequestID (X-Request-Id), request log and panic recovery.
  • internal/app: hand-written container closing in reverse order, also on a start that fails halfway; the server with its drain.
  • Terraform sets CANVAS_ENV=prod; spec 8.3 and 15.4; .env.example, launch.json, THIRD_PARTY_LICENSES; RUN.md T16 done.

…n router, container (T16)

- cmd/server: signals, errgroup, one report per failure, a stop during the
  start exits 0; the port is bound before the startup line.
- internal/config: viper over declared CANVAS_* variables only; CANVAS_ENV
  local by default and prod-only where K_SERVICE is set; the shutdown budget
  shared between drain and close.
- internal/logger, internal/apierror: Cloud Run keys; flat {code, message}
  with optional details.
- internal/transport/http: gin router, /health on GET and HEAD, 404 and 405
  as apierror, LastResort, SecurityHeaders, RequestID (X-Request-Id),
  request log and panic recovery.
- internal/app: hand-written container closing in reverse order, also on a
  start that fails halfway; the server with its drain.
- Terraform sets CANVAS_ENV=prod; spec 8.3 and 15.4; .env.example,
  launch.json, THIRD_PARTY_LICENSES; RUN.md T16 done.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U1MCDC5QUpgX5xmPSJYn5W
Comment thread internal/transport/http/middleware/logger.go Fixed
Comment thread internal/transport/http/middleware/logger.go Fixed
Comment thread internal/transport/http/middleware/logger.go Fixed
Comment thread internal/transport/http/middleware/recovery.go Fixed
@codecov

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.45361% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/server/main.go 88.37% 5 Missing ⚠️
internal/logger/logger.go 97.43% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

… a closed set (T16, PR review)

CodeQL flagged the request log and the last-resort line as carrying user
input: the client's X-Request-Id and the request's method. No client of the
service needs its id kept, so the header is no longer read; the method is
written as one of the service's own words. Recorded as R68.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U1MCDC5QUpgX5xmPSJYn5W
CodeQL's gin model treats Context.FullPath as user input, so the four
go/log-injection alerts stayed after the id and the method were fixed. The
route is now written as a pattern from the table of routes the router
registered, read once at the first request; the probe filter uses the same
name. R68 and RUN.md say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U1MCDC5QUpgX5xmPSJYn5W
@sonarqubecloud

Copy link
Copy Markdown

@RyazanovAlexander
RyazanovAlexander merged commit dda63b4 into main Oct 16, 2026
23 checks passed
@RyazanovAlexander
RyazanovAlexander deleted the t16-service-skeleton branch October 16, 2026 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants