support

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Application scenarios: - Attach the runtime container onto request-scoped or task-scoped contexts. - Give middleware, handlers, and background jobs a lightweight way to access container-bound capabilities. - Keep container context keys private and collision-free.

适用场景: - 将运行时容器挂到请求级或任务级 context 上。 - 为 middleware、handler 和后台任务提供轻量级容器访问路径。 - 保持容器相关 context key 私有且避免冲突。

Application scenarios: - Propagate request-scoped locale information through context. - Let validation, response shaping, and business handlers read the effective locale consistently. - Keep locale-related context keys private and collision-free.

适用场景: - 在 context 中透传请求级 locale 信息。 - 让校验、响应整形和业务 handler 统一读取当前 locale。 - 保持 locale 相关 context key 私有且避免冲突。

Application scenarios: - Propagate request ID and trace ID through request-scoped context. - Give middleware, logging, tracing, and handlers one shared access path to correlation identifiers. - Keep identifier context keys private to avoid collisions across packages.

适用场景: - 在请求级 context 中透传 request ID 和 trace ID。 - 为 middleware、日志、tracing 和 handler 提供统一的关联标识读取路径。 - 保持标识相关 context key 私有,避免跨包冲突。

Application scenarios: - Propagate tenant identity through request-scoped or task-scoped context. - Support multi-tenant business flows without coupling tenant access to one transport layer. - Keep tenant context keys private and collision-free.

适用场景: - 在请求级或任务级 context 中透传租户身份。 - 支持多租户业务流程,而不把租户读取绑定到某一种 transport 层。 - 保持 tenant context key 私有且避免冲突。

Application scenarios: - Store validated request payloads in context for downstream reuse. - Avoid repeated bind/validate work across middleware and handlers. - Keep validated-body context keys private and collision-free.

适用场景: - 在 context 中存储已经完成校验的请求体,供下游复用。 - 避免 middleware 和 handler 之间重复做 bind/validate。 - 保持 validated-body context key 私有且避免冲突。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContainerContext

func FromContainerContext(ctx context.Context) (any, bool)

FromContainerContext reads a container-like object from the context.

FromContainerContext 从 context 中读取容器对象。

func FromLocaleContext

func FromLocaleContext(ctx context.Context) (string, bool)

FromLocaleContext reads locale information from context.

FromLocaleContext 从 context 中读取 locale 信息。

func FromRequestIDContext

func FromRequestIDContext(ctx context.Context) (string, bool)

FromRequestIDContext reads request ID from context.

FromRequestIDContext 从 context 中读取 request ID。

func FromTenantContext

func FromTenantContext(ctx context.Context) (string, bool)

FromTenantContext reads tenant identity from context.

FromTenantContext 从 context 中读取租户身份。

func FromTraceIDContext

func FromTraceIDContext(ctx context.Context) (string, bool)

FromTraceIDContext reads trace ID from context.

FromTraceIDContext 从 context 中读取 trace ID。

func FromValidatedBodyContext

func FromValidatedBodyContext(ctx context.Context) (any, bool)

FromValidatedBodyContext reads a validated body from context.

FromValidatedBodyContext 从 context 中读取已校验请求体。

func NewContainerContext

func NewContainerContext(ctx context.Context, c any) context.Context

NewContainerContext stores a container-like object into the context.

NewContainerContext 将容器对象写入 context。

func NewLocaleContext

func NewLocaleContext(ctx context.Context, locale string) context.Context

NewLocaleContext stores locale information in context.

NewLocaleContext 将 locale 信息写入 context。

func NewRequestIDContext

func NewRequestIDContext(ctx context.Context, requestID string) context.Context

NewRequestIDContext stores request ID in context.

NewRequestIDContext 将 request ID 写入 context。

func NewTenantContext

func NewTenantContext(ctx context.Context, tenant string) context.Context

NewTenantContext stores tenant identity in context.

NewTenantContext 将租户身份写入 context。

func NewTraceIDContext

func NewTraceIDContext(ctx context.Context, traceID string) context.Context

NewTraceIDContext stores trace ID in context.

NewTraceIDContext 将 trace ID 写入 context。

func NewValidatedBodyContext

func NewValidatedBodyContext(ctx context.Context, body any) context.Context

NewValidatedBodyContext stores a validated body in context.

NewValidatedBodyContext 将已校验请求体写入 context。

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL