This commit is contained in:
@@ -132,6 +132,28 @@ func GetUserAgentFromContext(ctx context.Context) *string {
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetRequestPathFromContext 从 context 中提取请求路径。
|
||||
func GetRequestPathFromContext(ctx context.Context) *string {
|
||||
if ctx == nil {
|
||||
return nil
|
||||
}
|
||||
if requestPath, ok := ctx.Value(constants.ContextKeyRequestPath).(string); ok {
|
||||
return &requestPath
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetRequestMethodFromContext 从 context 中提取请求方法。
|
||||
func GetRequestMethodFromContext(ctx context.Context) *string {
|
||||
if ctx == nil {
|
||||
return nil
|
||||
}
|
||||
if requestMethod, ok := ctx.Value(constants.ContextKeyRequestMethod).(string); ok {
|
||||
return &requestMethod
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetUserToFiberContext 将用户信息设置到 Fiber context 的 Locals 中
|
||||
// 同时也设置到标准 context 中,便于 GORM 查询使用
|
||||
func SetUserToFiberContext(c *fiber.Ctx, info *UserContextInfo) {
|
||||
|
||||
Reference in New Issue
Block a user