Documentation ¶
Index ¶
- Constants
- Variables
- func Bearer(tok string) string
- func BindClientAuth(ctx Context, source token.Source) error
- func BindHead(ctx Context, options HeadReadFunc)
- func BindServerAuth(ctx Context, source token.Source) error
- func ContentTypeTo(ct string) string
- 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 GetSystem(ctx Context) app.System
- func GetTokenSource(ctx Context) token.Source
- func GetUid(ctx Context) int64
- func HeadInt64(ctx Context, key string) int64
- func ParamInt64(ctx Context, key string) int64
- func QueryInt64(ctx Context, key string) int64
- func Send(ctx Context, result result.Result, data interface{})
- func SendException(ctx Context, req request.HeadV2)
- func SendStatusNoHead(ctx Context, httpCode int, result result.Result, data interface{})
- func SendWithHead(ctx Context, req request.HeadV2, result result.Result, data interface{})
- func SendWithStatus(ctx Context, httpCode int, req request.HeadV2, result result.Result, ...)
- func SetUid(ctx Context, uid string)
- type Base
- type CacheContext
- type Context
- type HeadReadFunc
- type Header
- type HeaderContext
- type HttpContext
- type Key
- 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
Constants ¶
View Source
const ( UNK = "unk" XML = "xml" JSON = "json" PLAIN = "plain" MimeJSON = "application/json" MimeHTML = "text/html" MimeXML = "application/xml" MimeXML2 = "text/xml" MimePlain = "text/plain" MimePOSTForm = "application/x-www-form-urlencoded" MimeMultipartPOSTForm = "multipart/form-data" MimePROTOBUF = "application/x-protobuf" MimeMSGPACK = "application/x-msgpack" MimeMSGPACK2 = "application/msgpack" MimeYAML = "application/x-yaml" )
View Source
const ( CSysVersion = "SysVersion" CDeviceId = "DeviceId" CModel = "Model" CWifi = "Wifi" CChannel = "Channel" CExtInfo = "ExtInfo" CTerminal = "Terminal" CAppId = "AppId" CVersion = "Version" CSeqId = "SeqId" CSource = "Source" CToken = "Authorization" CTimeAt = "TimeAt" )
Variables ¶
View Source
var ( KHead = Key{"HEADER", "it is api.Request object"} KToken = Key{"TOKEN", "is req token object"} KUid = Key{"UID", "uid"} )
View Source
var DefErrorHttpCode = http.StatusOK
Functions ¶
func BindHead ¶ added in v0.5.22
func BindHead(ctx Context, options HeadReadFunc)
func ContentTypeTo ¶ added in v0.1.2
func GetClientIP ¶
func GetContentType ¶
func GetTokenSource ¶ added in v0.5.18
func ParamInt64 ¶
func QueryInt64 ¶
func SendException ¶
func SendStatusNoHead ¶ added in v0.5.19
func SendWithHead ¶ added in v0.5.25
func SendWithStatus ¶ added in v0.4.6
Types ¶
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 HeadReadFunc ¶ added in v0.5.19
type Header ¶
func (*Header) HasDeviceId ¶
type HeaderContext ¶ added in v0.1.4
type HttpContext ¶ added in v0.1.4
type ReqHead ¶
type ReqHead struct { Version string `json:"version"` Source string `json:"source"` SeqId string `json:"seqId"` RecvAt int64 `json:"timeAt"` //收到请求时间 ReqAt 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.