Documentation
¶
Index ¶
Constants ¶
View Source
const ( ContextKey = "gomooth_http_context" RequestRawBodyDataKey = "request_raw_body" )
Variables ¶
This section is empty.
Functions ¶
func WithRawRequestBody ¶
func WithRawRequestBody(body []byte) func(*httpContext)
Types ¶
type IHttpContext ¶
type IHttpContext interface {
context.Context
// TraceID 链路追踪标志
TraceID() string
// User 用户信息
User() *User
// IsRole 判断用户角色
IsRole(role IRole) bool
// Set 设置参数
// 会根据 value 的类型,自动设置对应属性的值,目前支持: User
Set(key string, value interface{}) IHttpContext
// StorageTo 将已变更的数据,存储到 gin 上下文中,继续传输
StorageTo(ctx *gin.Context) bool
}
func MustParse ¶
func MustParse(ctx context.Context) (IHttpContext, error)
MustParse 从 gin 上下文中解析自定义上下文
func NewContext ¶
func NewContext(opts ...func(*httpContext)) IHttpContext
Click to show internal directories.
Click to hide internal directories.