oapi-codegen icon indicating copy to clipboard operation
oapi-codegen copied to clipboard

feature(std-http-server): option to inject request metadata into context

Open chaseisabelle opened this issue 5 months ago • 3 comments

Added an option to inject request metadata into the context for the std-http-server. This will be useful for downstream logging, metrics, tracing, observability, and custom authorization implementations.

Checklist:

  • All make commands (tidy, test, generate, and lint) have been run ✅
  • Default is false/off to preserve existing behavior ✅
  • Added test cases and mock std-http-server ✅
  • Generated code has been committed for review ✅

Example:

// set the option to enable metadata context injection
han := oapi.HandlerWithOptions(srv, StdHTTPServerOptions{
  WithRequestMetadata: true,
})
// get the injected metadata from the context 
md := oapi.RequestMetadataFromContext(ctx)

opID := md.OperationID
path := md.RequestRoute

chaseisabelle avatar Aug 30 '25 16:08 chaseisabelle

Kusari Inspector

Kusari Analysis Results:

Proceed with these changes
✅ No Flagged Issues Detected All values appear to be within acceptable risk parameters.

No pinned version dependency changes, code issues or exposed secrets detected!

[!NOTE] View full detailed analysis result for more information on the output and the checks that were run.


@kusari-inspector rerun - Trigger a re-analysis of this PR @kusari-inspector feedback [your message] - Send feedback to our AI and team See Kusari's documentation for setup and configuration. Commit: 54c773c31bfdb55557dbb19413cd091ca8ad3293, performed at: 2025-09-28T04:16:46Z

Found this helpful? Give it a 👍 or 👎 reaction!

kusari-inspector[bot] avatar Aug 30 '25 16:08 kusari-inspector[bot]

Kusari PR Analysis rerun based on - c19ae607bfd14104cbb49f8124b541d6588f0cde performed at: 2025-09-13T21:06:03Z - link to updated analysis

kusari-inspector[bot] avatar Sep 13 '25 21:09 kusari-inspector[bot]

Kusari PR Analysis rerun based on - 54c773c31bfdb55557dbb19413cd091ca8ad3293 performed at: 2025-09-28T04:17:03Z - link to updated analysis

kusari-inspector[bot] avatar Sep 28 '25 04:09 kusari-inspector[bot]