Documentation ¶
Index ¶
- Constants
- Variables
- func Cors() gin.HandlerFunc
- type Context
- type Ctx
- func (receiver *Ctx) Fail(err error)
- func (receiver *Ctx) Gin() *gin.Context
- func (receiver *Ctx) Id() uint64
- func (receiver *Ctx) IdStr() string
- func (receiver *Ctx) InitUser()
- func (receiver *Ctx) Success(data interface{})
- func (receiver *Ctx) Token() string
- func (receiver *Ctx) User() interface{}
Constants ¶
View Source
const UserIdKey = "user_id"
View Source
const UserKey = "user"
Variables ¶
View Source
var NewContext = func(ctx *gin.Context) Context { return &Ctx{ Context: ctx, } }
NewContext 最好在中间件已经赋值以下两个参数 ginCtx.Set("user", nil) ginCtx.Set("user_id", nil)
View Source
var UserModel interface{}
UserModel 不能赋值指针
Functions ¶
Types ¶
type Context ¶
type Context interface { Success(data interface{}) Fail(err error) Gin() *gin.Context Token() string Id() uint64 IdStr() string User() interface{} JSON(code int, obj interface{}) String(code int, format string, values ...interface{}) Param(key string) string Query(key string) string PostForm(key string) string BindJSON(obj interface{}) error Status(code int) Set(key string, value interface{}) Get(key string) (value interface{}, exists bool) AbortWithStatus(code int) Next() GetString(key string) string GetBool(key string) bool GetInt(key string) int GetInt64(key string) int64 GetFloat64(key string) float64 GetTime(key string) time.Time GetDuration(key string) time.Duration GetStringSlice(key string) []string GetStringMap(key string) map[string]interface{} GetStringMapString(key string) map[string]string GetStringMapStringSlice(key string) map[string][]string }
Click to show internal directories.
Click to hide internal directories.