Documentation ¶
Index ¶
- Constants
- Variables
- func Bearer(tok string) string
- func BindHead(ctx Context, option HeadOption)
- func ContentTypeTo(ct string) string
- func EventTypeExist(opts ...option.Option) (int32, bool)
- func Get[T any](ctx Context, key string) T
- func GetApp(ctx Context) app.Info
- func GetClientIP(ctx Context) string
- func GetContentType(ctx Context) string
- func GetCustom(ctx Context) interface{}
- func GetInt64Uid(ctx Context) int64
- func GetSystem(ctx Context) app.System
- func GetToken(ctx Context, keys ...string) (string, error)
- func GetTokenSource(ctx Context) token.Source
- func GetUid(ctx Context) string
- func HeadInt64(ctx Context, key string) int64
- func MustGet[T any](ctx Context, key string) T
- func ParamInt64(ctx Context, key string) int64
- func QueryInt64(ctx Context, key string) int64
- func SetInt64Uid(ctx Context, uid int64)
- func SetUid(ctx Context, uid string)
- func TokenReq(ctx Context) (string, error)
- func WithHeadOption(ctx Context, header *Header)
- type Api
- func (a *Api) GetBuilder() ResponseBuilder
- func (a *Api) SendEx(ctx Context, httpCode int, result result.Result, data interface{}, ...)
- func (a *Api) SendException(ctx Context, httpCode int, req request.HeadV2, opts ...option.Option)
- func (a *Api) SendHead(ctx Context, httpCode int, req request.HeadV2, result result.Result, ...)
- func (a *Api) SendMaybeError(ctx Context, httpCode int, data interface{}, err error, opts ...option.Option)
- func (a *Api) SendNHead(ctx Context, httpCode int, result result.Result, data interface{}, ...)
- type Base
- type CacheContext
- type Context
- type EventType
- type HeadOption
- type Header
- type HeaderContext
- type HttpContext
- type PageOption
- type ReqHead
- func (h *ReqHead) GetRecvAt() int64
- func (h *ReqHead) GetReqAt() int64
- func (h *ReqHead) GetSeqId() string
- func (h *ReqHead) GetSource() string
- func (h *ReqHead) GetTimeOut() time.Duration
- func (h *ReqHead) GetVersion() string
- func (h *ReqHead) SetSource(source string)
- func (h *ReqHead) SetTimeOut(duration time.Duration)
- type Request
- type ResHead
- type Response
- type ResponseBuilder
Constants ¶
View Source
const ( Head = "HEADER" Token = "TOKEN" Uid = "UID" )
View Source
const ( UNK = "unk" XML = "xml" JSON = "json" PLAIN = "plain" ContentType = "Content-Type" )
View Source
const ( CSysVersion = "X-H79-SysVersion" CDeviceId = "X-H79-DeviceId" CModel = "X-H79-Model" CWifi = "X-H79-Wifi" CChannel = "X-H79-Channel" CExtInfo = "X-H79-ExtInfo" CTerminal = "terminal" CAppId = "appId" CVersion = "version" CSeqId = "seqId" CSource = "source" CTimeAt = "timeAt" CToken = "Authorization" CSign = "sign" CTimeStamp = "timestamp" XReqTime = "X-ReqTime" XSeqId = "X-SeqNo" XSign = "X-Sign" XTimeStamp = "X-Timestamp" )
View Source
const ( TypePage = iota + 1000 TypeEventType )
Variables ¶
View Source
var DefErrorHttpCode = http.StatusOK
Functions ¶
func BindHead ¶ added in v0.5.22
func BindHead(ctx Context, option HeadOption)
func ContentTypeTo ¶ added in v0.1.2
func GetClientIP ¶
func GetContentType ¶
func GetInt64Uid ¶ added in v1.0.36
func GetTokenSource ¶ added in v0.5.18
func ParamInt64 ¶
func QueryInt64 ¶
func SetInt64Uid ¶ added in v1.0.36
func WithHeadOption ¶ added in v1.0.1
Types ¶
type Api ¶ added in v1.8.20
type Api struct {
Builder ResponseBuilder
}
func (*Api) GetBuilder ¶ added in v1.8.20
func (a *Api) GetBuilder() ResponseBuilder
func (*Api) SendException ¶ added in v1.8.20
func (*Api) SendMaybeError ¶ added in v1.8.20
type CacheContext ¶ added in v0.1.4
type Context ¶ added in v0.1.2
type Context interface { HttpContext() HttpContext HeaderContext() HeaderContext CacheContext() CacheContext AuthContext() token.Engine }
type HeadOption ¶ added in v1.0.1
type Header ¶
func (*Header) HasDeviceId ¶
type HeaderContext ¶ added in v0.1.4
type HttpContext ¶ added in v0.1.4
type PageOption ¶ added in v1.8.38
func WithPageOption ¶ added in v1.8.38
func WithPageOption(total int64) PageOption
func (PageOption) String ¶ added in v1.8.38
func (t PageOption) String() string
func (PageOption) Type ¶ added in v1.8.38
func (t PageOption) Type() int
func (PageOption) Value ¶ added in v1.8.38
func (t PageOption) Value() interface{}
type ReqHead ¶
type ReqHead struct { Version string `form:"version" binding:"-" json:"version"` Source string `form:"source" binding:"-" json:"source"` SeqId string `form:"seqId" binding:"-" json:"seqId"` ReqAt int64 `form:"timeAt" binding:"-" json:"timeAt"` //请求者的时间(客户端时间) RecvAt int64 `json:"-"` //收到请求时间(服务端时间) TimeOut time.Duration `json:"-"` }
func GetReqHead ¶
func (*ReqHead) GetTimeOut ¶
GetTimeOut request.HeadV2 interface
func (*ReqHead) GetVersion ¶
GetVersion request.Head interface
func (*ReqHead) SetTimeOut ¶
SetTimeOut request.HeadV2 interface
type Request ¶
func NewRequest ¶
func NewRequest() Request
type ResHead ¶
type ResHead struct { result.Result Version string `json:"version"` //版本,请求者版本 Source string `json:"source,omitempty"` //请求源,可以请求者填写 SeqId string `json:"seqId,omitempty"` //请求序号,由请求者定义,服务器原路返回 TimeAt int64 `json:"timeAt,omitempty"` //服务收到请求的时间(ms) DiffAt int64 `json:"diffAt,omitempty"` //客户端与服务端时间差值(ms) SpendAt int64 `json:"spendAt,omitempty"` //从服务收到请求到响应完成,所花的时长(ms) ServerAt int64 `json:"serverAt,omitempty"` //服务器时间,豪秒,用于检验对时(ms) LogId string `json:"logId,omitempty"` }
func NewResHead ¶
Click to show internal directories.
Click to hide internal directories.