Documentation
¶
Overview ¶
Package httpctx provides shared helpers for extracting authentication context from gin-based HTTP handlers.
Both the native AgentBox API and the E2B-compatible API use oapi-codegen's strict server mode, which passes *gin.Context directly as context.Context. These helpers safely extract AuthInfo regardless of whether the context has been wrapped by context.WithValue.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthFrom ¶
AuthFrom extracts domain.AuthInfo from the context.
It first tries a direct *gin.Context type assertion (fast path when the context has not been wrapped). If that fails, it uses ctx.Value("auth") which traverses through any context.WithValue layers and reaches the underlying gin.Context's key store.
func GinFromCtx ¶
GinFromCtx extracts the *gin.Context from a context.Context. Returns nil if the context is not or does not wrap a *gin.Context.
func WithClientCancel ¶ added in v0.0.13
WithClientCancel returns a context that is cancelled when the HTTP client goes away, for a handler that waits on something long enough to outlive its caller.
The strict server hands each handler the *gin.Context itself, and with the engine's ContextWithFallback off (the default) its Done/Err/Deadline report nothing: a client that disconnects is invisible to the handler, which keeps waiting and completes work nobody will receive. For create that means a sandbox claimed, armed and held for a caller that never learns its ID, so it stays allocated until the idle sweep.
Cancellation is opt-in per handler rather than switched on for the engine: handlers that make several writes, and roll back with the same context, would otherwise abort half-way and fail the rollback too. Values (auth, the gin context itself) still resolve through the *gin.Context, so AuthFrom and GinFromCtx keep working on the result.
Types ¶
This section is empty.