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 interface{})
// SetMeta与Set的区别是 SetMeta设置的key在ctx.GetHeaderMap()时会返回
// 而这个map通常是ddns client请求别的服务时需要透传过去的Header
// 故如果你觉得这个key需要进行透传,请用SetMeta
SetMeta(key string, value string)
WithValue(key interface{}, val interface{}) IContext
WithCancel() (IContext, CancelFunc)
WithTimeout(d time.Duration) (IContext, CancelFunc)
GetHeaders() http.Header
Get(key string) (value interface{}, exists bool)
GetString(key string) (v string)
GetInt64(key string) (i int64)
GetInt(key string) (i int)
GetGoContext() context.Context
GetAllKey() map[string]interface{}
GetHttpRequest() *http.Request
}
func Background ¶
func Background() IContext
func NewContext ¶
func NewContext() IContext
func NewContextWithGinHeader ¶
Click to show internal directories.
Click to hide internal directories.