mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-29 14:06:36 +08:00
63cd906cfc
- Merge all files inside openflare-server to the repository root directory. - Relocate agent, relay, and flared subprojects from internal/ to internal/apps/. - Combine docker-compose files and update build context paths to root. - Update GitHub workflows and Dockerfiles to refer to new directories and package names. - Rewrite Go package imports across all files. - Resolve database renew test race condition and clean up docs.
23 lines
517 B
Go
23 lines
517 B
Go
// Copyright 2026 Arctel.net
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package oauth
|
|
|
|
import "github.com/gin-gonic/gin"
|
|
|
|
// GetFromContext 从 Gin 请求上下文获取指定类型的值。
|
|
func GetFromContext[T any](c *gin.Context, key string) (T, bool) {
|
|
value, exists := c.Get(key)
|
|
if !exists {
|
|
var zero T
|
|
return zero, false
|
|
}
|
|
typed, ok := value.(T)
|
|
return typed, ok
|
|
}
|
|
|
|
// SetToContext 设置值到 Gin 请求上下文。
|
|
func SetToContext[T any](c *gin.Context, key string, value T) {
|
|
c.Set(key, value)
|
|
}
|