types

package
v1.1.0-alpha.14 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiVersion

type ApiVersion string

ApiVersion 版本号

func (ApiVersion) Verify

func (av ApiVersion) Verify() bool

type BodyProperty

type BodyProperty string

BodyProperty 响应正文属性

const (
	BodyPropertyRaw  BodyProperty = "raw"
	BodyPropertyText BodyProperty = "text"
	BodyPropertyHtml BodyProperty = "html"
	BodyPropertyFull BodyProperty = "full"
)

func (BodyProperty) Verify

func (bp BodyProperty) Verify() bool

type HttpContext

type HttpContext struct {
	// contains filtered or unexported fields
}

func NewHttpContext

func NewHttpContext() *HttpContext

NewHttpContext 创建自定义上下文

func ParserHttpContext

func ParserHttpContext(ctx context.Context) (*HttpContext, error)

ParserHttpContext 从 gin 上下文中解析自定义上下文

func (*HttpContext) Deadline

func (sc *HttpContext) Deadline() (deadline time.Time, ok bool)

func (*HttpContext) Done

func (sc *HttpContext) Done() <-chan struct{}

func (*HttpContext) Err

func (sc *HttpContext) Err() error

func (*HttpContext) HasRole

func (sc *HttpContext) HasRole(roles []IRole) bool

HasRole 判断用户角色

func (*HttpContext) IsRole

func (sc *HttpContext) IsRole(role IRole) bool

IsRole 判断用户角色

func (*HttpContext) Logger

func (sc *HttpContext) Logger() xlog.XLogger

func (*HttpContext) Set

func (sc *HttpContext) Set(key string, value interface{})

Set 设置参数 会根据 value 的类型,自动设置对应属性的值,目前支持: ApiVersion, BodyProperty, types.User, xlog.XLogger

func (*HttpContext) StorageTo

func (sc *HttpContext) StorageTo(ctx *gin.Context) bool

StorageTo 将已变更的数据,存储到 gin 上下文中,继续传输

func (*HttpContext) TraceId

func (sc *HttpContext) TraceId() string

func (*HttpContext) User

func (sc *HttpContext) User() *User

func (*HttpContext) Value

func (sc *HttpContext) Value(key interface{}) interface{}

type IRole

type IRole interface {
	String() string
}

type SearchRequest

type SearchRequest struct {
	// 数据开始位置
	Start int64 `form:"start"`
	// 返回数据条数
	Limit int64 `form:"limit"`
	// 排序规则:sort=otc_type,-created_at,*custom
	// 以符号开头,可选符号:(+或空 正序)(- 倒序)(* 自定义复杂排序标识关键词)
	Sort string `form:"sort"`
}

SearchRequest 通用搜索请求

func (SearchRequest) GetLimit

func (sr SearchRequest) GetLimit() int64

GetLimit 获得分页数据条数

type ToRole

type ToRole func(role string) (IRole, error)

ToRole 转换成角色 IRole

type User

type User struct {
	ID      uint
	Account string
	Name    string
	Roles   []IRole
}

User 用户基本信息

Jump to

Keyboard shortcuts

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