http

package
v0.5.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2024 License: MIT Imports: 6 Imported by: 6

Documentation

Index

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

func Cors

func Cors() gin.HandlerFunc

Cors 跨域

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
}

type Ctx

type Ctx struct {
	*gin.Context

	UserInfo interface{}
}

func (*Ctx) Fail

func (receiver *Ctx) Fail(err error)

func (*Ctx) Gin

func (receiver *Ctx) Gin() *gin.Context

func (*Ctx) Id

func (receiver *Ctx) Id() uint64

func (*Ctx) IdStr added in v0.5.15

func (receiver *Ctx) IdStr() string

func (*Ctx) InitUser added in v0.5.15

func (receiver *Ctx) InitUser()

func (*Ctx) Success

func (receiver *Ctx) Success(data interface{})

func (*Ctx) Token

func (receiver *Ctx) Token() string

func (*Ctx) User

func (receiver *Ctx) User() interface{}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL