You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(router)!: add build and config identities (#123)
* feat(scontext): add runtime identity providers
* feat(router)!: group application dependencies
BREAKING CHANGE: NewRouter now accepts a RouterDependencies[T, U] value instead of separate authentication and user ID callbacks.
On success, `authenticate` must return a usable `*User` and `true`. SRouter passes that pointer to `userID`, stores the resulting ID in `SRouterContext`, and stores the user pointer as well when `RouterConfig.AddUserObjectToCtx` is true.
53
56
54
-
The callbacks are required only if at least one compiled route resolves to `AuthOptional` or `AuthRequired`. `Build` fails with a descriptive error when such a route exists and either callback is nil. A router containing only `NoAuth` routes can use:
57
+
The authentication dependencies are required only if at least one compiled route resolves to `AuthOptional` or `AuthRequired`. `Build` fails with a descriptive error when such a route exists and either dependency is nil. A router containing only `NoAuth` routes can use:
Calling `Build` during startup is recommended so callback and route configuration errors are reported before serving traffic. Otherwise the first request triggers the build.
@@ -148,7 +151,7 @@ Choose one of these arrangements when user-based limiting must use custom authen
148
151
- Wrap the whole router with authentication before assigning it to `http.Server.Handler`:
@@ -21,7 +26,17 @@ For requests that reach normal route dispatch, SRouter emits one `"Request summa
21
26
-`TraceIDBufferSize > 0`, which enables automatic trace IDs on matched routes and request summaries.
22
27
-`EnableTraceLogging`, which enables request summaries independently of trace IDs.
23
28
24
-
The summary contains `method`, `path`, `status`, `duration`, `bytes`, `ip`, and `user_agent`. For a matched route, it also contains `trace_id` when automatic trace generation is enabled. An unmatched 404 or 405 still receives a summary, but it never enters the per-route trace middleware and therefore has no automatically generated `trace_id`.
29
+
The summary contains `method`, `path`, `status`, `duration`, `bytes`, `ip`, and `user_agent`. It also contains configured `build_id` and `config_id` values when available. For a matched route, it contains `trace_id` when automatic trace generation is enabled. An unmatched 404 or 405 still receives a summary, but it never enters the per-route trace middleware and therefore has no automatically generated `trace_id`.
30
+
31
+
SRouter adds available runtime identities to its request-bound authentication,
32
+
timeout, panic recovery, handled HTTP error, lazy-build failure, and JSON-response
33
+
write-failure logs. Startup and route-registration logs have no request context
34
+
and remain unchanged.
35
+
36
+
Runtime identities are opaque, log-safe application values. SRouter samples
37
+
them once per request and does not propagate them through headers. Background
38
+
workers may install already-sampled values with `scontext.WithBuildID` and
With the built-in middleware, non-empty `Namespace` and `Subsystem` values become the default tags `service` and `subsystem`, respectively. They do not configure a backend's native namespace or subsystem. For example, the Prometheus adapter's namespace and subsystem are separately supplied to `prometheus.NewPrometheusRegistry` and become metric-name prefixes.
0 commit comments