Commit graph

25 commits

Author SHA1 Message Date
Snider
deab5f23ea chore: pin forge deps to v0.0.1 tags for Go 1.26 compat
Go 1.26 rejects non-semver version strings (like 'main') in go.mod.
Tags v0.0.1 now exist on all forge repos — workspace still overrides
for local development.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-22 20:15:05 +00:00
Snider
b94bee067e chore: use workspace-resolved versions, drop replace directives
Forge module versions now use main branch resolution via ~/Code/go.work
workspace. Removes local replace directives — the central go.work handles
all cross-repo resolution during development.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-22 19:49:36 +00:00
Snider
9d35070573 feat: migrate api commands from CLI
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-21 19:38:14 +00:00
Snider
e94283b06c feat: add spec export helpers for JSON and YAML output
ExportSpec writes the OpenAPI spec to any io.Writer in JSON or YAML
format. ExportSpecToFile is a convenience wrapper that creates the
parent directory and writes to a file path. Adds gopkg.in/yaml.v3
for YAML marshalling.

Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 00:51:58 +00:00
Snider
8ba1716215 feat: add WithTracing OpenTelemetry distributed tracing middleware
Adds WithTracing(serviceName) option using the official otelgin
instrumentation (go.opentelemetry.io/contrib/.../otelgin v0.65.0).
Each request produces a span with http.request.method, http.route,
and http.response.status_code attributes. Trace context is propagated
via W3C traceparent headers.

Also exposes NewTracerProvider() convenience helper for wiring up
a synchronous TracerProvider in tests and simple deployments.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-21 00:24:46 +00:00
Snider
f5d2f45b94 feat: add WithExpvar runtime metrics endpoint
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 00:20:31 +00:00
Snider
32b3680402 feat: add WithPprof runtime profiling endpoints
Registers Go pprof handlers at /debug/pprof/ via gin-contrib/pprof
when the WithPprof() option is enabled. Uses the same flag-in-build()
pattern as WithSwagger() — routes are only mounted when explicitly
opted in.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-21 00:18:05 +00:00
Snider
d517fa2d71 feat: add WithGraphQL endpoint and playground support
Mount a gqlgen ExecutableSchema as a Gin handler at /graphql with
optional playground UI at /graphql/playground. Supports custom path
via WithGraphQLPath().

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-21 00:12:25 +00:00
Snider
36d77ea015 feat: add WithI18n locale detection middleware
Lightweight Accept-Language header parsing using golang.org/x/text/language
for RFC 5646 language matching with quality weighting. Provides GetLocale()
and GetMessage() context helpers for handlers. Bridges to go-i18n grammar
engine later — no heavy file-based i18n dependencies needed.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-21 00:08:17 +00:00
Snider
a612d85dba feat: add WithLocation reverse proxy header detection middleware
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 00:04:28 +00:00
Snider
7b3f99e421 feat: add WithHTTPSign HTTP signature verification middleware
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 23:57:30 +00:00
Snider
67dcc83a37 feat: add WithAuthz Casbin authorisation middleware
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 23:49:02 +00:00
Snider
e00ef00db8 feat: add WithSessions server-side session middleware
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 23:44:46 +00:00
Snider
64a8b16ca2 feat: add WithBrotli response compression middleware
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 23:37:46 +00:00
Snider
daae6f7879 feat: add WithStatic static file serving middleware
Adds WithStatic(urlPrefix, root) option using gin-contrib/static to
serve files from a local directory at the given URL prefix. Directory
listing is disabled for security.

Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 23:23:17 +00:00
Snider
68ba956587 feat: add WithGzip response compression middleware
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 23:20:46 +00:00
Snider
6521b90d26 feat: add WithTimeout per-request timeout middleware
Wraps gin-contrib/timeout to enforce per-request deadlines. When a
handler exceeds the configured duration, the client receives a 504
Gateway Timeout with the standard Fail("timeout", ...) error envelope.

Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 23:18:24 +00:00
Snider
f5ce02d661 feat: add WithSlog structured request logging middleware
Adds WithSlog(logger) option wrapping gin-contrib/slog for structured
request logging via Go's standard log/slog package. Logs method, path,
status code, latency, and client IP for every request. Falls back to
slog.Default() when nil is passed.

Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 23:14:15 +00:00
Snider
6bb7195cca feat: add WithSecure security headers middleware
Wraps gin-contrib/secure to set HSTS (1 year, includeSubdomains),
X-Frame-Options DENY, X-Content-Type-Options nosniff, and
Referrer-Policy strict-origin-when-cross-origin on all responses.

Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 23:10:52 +00:00
Snider
5cba2f2cd4 feat(authentik): add OIDC JWT validation middleware
Add JWT validation as a second authentication block in the Authentik
middleware. Direct API clients can now send Authorization: Bearer <jwt>
tokens validated via OIDC discovery (coreos/go-oidc). Forward-auth
headers take priority; JWT is only attempted when no user was extracted
from headers. Validation is permissive — failures continue without a
user context. OIDC providers are cached per issuer to avoid repeated
discovery.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 16:42:23 +00:00
Snider
095c38a8c4 feat: add Swagger UI endpoint with runtime spec serving
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 15:56:29 +00:00
Snider
22f8a6915c feat: add WebSocket endpoint and channel listing from StreamGroups
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 15:53:10 +00:00
Snider
d21734d8d9 feat: add bearer auth, request ID, and CORS middleware
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 15:49:35 +00:00
Snider
6f5fb69944 feat: add RouteGroup and StreamGroup interfaces
RouteGroup declares Name, BasePath, and RegisterRoutes for subsystems
to mount their endpoints onto a Gin router group. StreamGroup optionally
declares WebSocket channel names. Gin v1.11.0 added as dependency.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 15:44:58 +00:00
Snider
889391a3a7 chore: scaffold go-api module
EUPL-1.2 licence, module path forge.lthn.ai/core/go-api.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 15:42:16 +00:00