Documentation
¶
Index ¶
Constants ¶
View Source
const ( HeaderGinContextKey = "gin-context" HttpRequestKey = "Http-Request" )
http 的header
View Source
const CommonContextKey = "context"
Variables ¶
View Source
var Canceled = context.Canceled
View Source
var DeadlineExceeded = context.DeadlineExceeded
Functions ¶
func WithCancel ¶
func WithCancel(parent context.Context) (IContext, CancelFunc)
func WithContext ¶
func WithTimeout ¶
Types ¶
type CancelFunc ¶
type CancelFunc = context.CancelFunc
type IContext ¶
type IContext interface {
context.Context
Set(key string, value any)
// SetMeta与Set的区别是 SetMeta设置的key在ctx.GetHeaderMap()时会返回
// 而这个map通常是ddns client请求别的服务时需要透传过去的Header
// 故如果你觉得这个key需要进行透传,请用SetMeta
SetMeta(key string, value string)
WithValue(key any, val any) IContext
WithCancel() (IContext, CancelFunc)
WithTimeout(d time.Duration) (IContext, CancelFunc)
GetHeaders() http.Header
Get(key string) (value any, exists bool)
GetString(key string) (v string)
GetInt64(key string) (i int64)
GetInt(key string) (i int)
GetGoContext() context.Context
GetAllKey() map[string]any
GetHttpRequest() *http.Request
LogInfo(msg string, fields ...log.Field)
LogError(msg string, fields ...log.Field)
}
func Background ¶
func Background() IContext
func Ginform ¶
Ginform 将 *gin.Context 或 IContext 统一转换为 IContext 参数类型为 any:gin v1.10+ 的 Context.Get 签名变为 Get(any),无法再用小接口约束
func NewContext ¶
func NewContext() IContext
func NewContextWithGinHeader ¶
Click to show internal directories.
Click to hide internal directories.