Documentation
¶
Index ¶
- Constants
- func EnsureTraceID(ctx context.Context) (context.Context, string)
- func ExtractContext(payload *map[string]any) context.Context
- func FromGinContext(c *gin.Context) context.Context
- func GenerateBusinessCode(identifier string) string
- func GetConfig(ctx context.Context) *config.Config
- func GetEmailSender(ctx context.Context) (email.Sender, error)
- func GetGinContext(ctx context.Context) (*gin.Context, bool)
- func GetProfile(ctx context.Context) any
- func GetProvider(ctx context.Context) string
- func GetStorage(ctx context.Context) (oss.StorageInterface, *storage.Config)
- func GetTenantID(ctx context.Context) string
- func GetToken(ctx context.Context) string
- func GetTraceID(ctx context.Context) string
- func GetUserID(ctx context.Context) string
- func GetValue(ctx context.Context, key string) any
- func SendEmailWithTemplate(ctx context.Context, recipientEmail string, template email.EmailTemplate) (string, error)
- func SetConfig(ctx context.Context, conf *config.Config) context.Context
- func SetEmailSender(ctx context.Context, sender email.Sender) context.Context
- func SetProfile(ctx context.Context, profile any) context.Context
- func SetProvider(ctx context.Context, provider string) context.Context
- func SetStorage(ctx context.Context, s oss.StorageInterface) context.Context
- func SetTenantID(ctx context.Context, uid string) context.Context
- func SetToken(ctx context.Context, token string) context.Context
- func SetTraceID(ctx context.Context, traceID string) context.Context
- func SetUserID(ctx context.Context, uid string) context.Context
- func SetValue(ctx context.Context, key string, val any) context.Context
- func WithGinContext(ctx context.Context, c *gin.Context) context.Context
Constants ¶
const (
TraceIDKey = "trace_id"
)
Variables ¶
This section is empty.
Functions ¶
func EnsureTraceID ¶
EnsureTraceID ensures that a trace ID exists in the context.
func ExtractContext ¶ added in v0.1.2
ExtractContext extracts context from payload map safely
func FromGinContext ¶
FromGinContext extracts the context.Context from *gin.Context.
func GenerateBusinessCode ¶
GenerateBusinessCode generate business code
format: Code+YYYYMM+AntifakeCODE+Serial, eg: CO2009110GA0001
func GetEmailSender ¶
GetEmailSender gets email sender from context.Context based on the configured provider
func GetGinContext ¶
GetGinContext extracts *gin.Context from context.Context if it exists.
func GetProfile ¶
GetProfile gets profile from context.Context.
func GetProvider ¶
GetProvider gets provider from context.Context.
func GetStorage ¶
GetStorage gets storage from context.Context
func GetTenantID ¶
GetTenantID gets tenant id from context.Context.
func GetTraceID ¶
GetTraceID gets trace id from context.Context or gin.Context.
func SendEmailWithTemplate ¶
func SendEmailWithTemplate(ctx context.Context, recipientEmail string, template email.EmailTemplate) (string, error)
SendEmailWithTemplate sends an email with a template
func SetEmailSender ¶
SetEmailSender sets email sender to context.Context
func SetProfile ¶
SetProfile sets profile to context.Context.
func SetProvider ¶
SetProvider sets provider to context.Context.
func SetStorage ¶
SetStorage sets storage to context.Context
func SetTenantID ¶
SetTenantID sets tenant id to context.Context.
func SetTraceID ¶
SetTraceID sets trace id to context.Context and gin.Context if available.
Types ¶
This section is empty.