Skip to content

Expose request ID context key as a public variable #58

@joejoe-am

Description

@joejoe-am

What’s the problem?

slog-gin currently stores its per-request ID under a private key:

const requestIDCtx = "slog-gin.request-id"

Because it’s unexported, anyone who wants to pull that ID out of a plain context.Context must hard-code the string literal, leading to brittle, “stringly-typed” code.

Why can’t I just use GetRequestID?

func GetRequestID(c *gin.Context) string

That helper only works with a Gin *gin.Context. In many architectures—where inner layers deal only in context.Context—you can’t import or depend on Gin types.

Happy to open a PR if this sounds reasonable!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions