Documentation ¶
Index ¶
- Constants
- Variables
- func Bearer(tok string) string
- func BindBase(ctx Context)
- func BindClientAuth(ctx Context)
- func BindServerAuth(ctx Context)
- func ChangeHeadSource(head *ReqHead)
- func ContentTypeTo(ct string) string
- func Get[T any](ctx Context, key string) T
- func GetAppId(ctx Context) string
- func GetAppVersion(ctx Context) string
- func GetClientIP(ctx Context) string
- func GetContentType(ctx Context) string
- func GetDeviceId(ctx Context) string
- func GetPlatform(ctx Context) string
- func GetSource(ctx Context) app.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 SendEx(ctx Context, req request.HeadEx, result result.Result, data interface{})
- func SendException(ctx Context, req request.HeadEx)
- func SendWithStatus(ctx Context, httpCode int, req request.HeadEx, result result.Result, ...)
- func SetUid(ctx Context, uid string)
- type Base
- type CacheContext
- type Context
- type Header
- type HeaderContext
- type HttpContext
- type Key
- type OptionsHeaderFunc
- type ReqHead
- 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 ( CSysVer = "sysver" CDeviceId = "deviceid" CModel = "model" CWifi = "wifi" CChannel = "channel" CExtInfo = "extinfo" CTerminal = "terminal" CAppId = "appid" CVersion = "version" CSeqid = "seqid" CSource = "source" CToken = "Authorization" )
Variables ¶
View Source
var ( DkReq = Key{"REQ", "it is api.Request object"} DkBase = Key{"BASE", "it is api.Base object"} DkToken = Key{"TOKEN", "is req token object"} DkUid = Key{"uid", "http: param 'uid'"} )
Functions ¶
func BindClientAuth ¶
func BindClientAuth(ctx Context)
func BindServerAuth ¶
func BindServerAuth(ctx Context)
func ChangeHeadSource ¶
func ChangeHeadSource(head *ReqHead)
func ContentTypeTo ¶ added in v0.1.2
func GetAppVersion ¶
func GetClientIP ¶
func GetContentType ¶
func GetDeviceId ¶
func GetPlatform ¶
func ParamInt64 ¶
func QueryInt64 ¶
func SendException ¶
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 }
type Header ¶
func NewHeader ¶
func NewHeader(req ReqHead, options ...OptionsHeaderFunc) *Header
func (*Header) HasDeviceId ¶
func (*Header) ReadFrom ¶ added in v0.1.4
func (h *Header) ReadFrom(ctx HeaderContext)
func (*Header) WriteTo ¶ added in v0.1.4
func (h *Header) WriteTo(ctx HeaderContext)
type HeaderContext ¶ added in v0.1.4
type HttpContext ¶ added in v0.1.4
type OptionsHeaderFunc ¶
type OptionsHeaderFunc func(h *Header)
type ReqHead ¶
type ReqHead struct { Version string `json:"version"` Source string `json:"source"` SeqId string `json:"seqid"` TimeAt int64 `json:"timeat"` TimeOut time.Duration `json:"-"` }
func GetReqHead ¶
func (*ReqHead) GetStartTime ¶
GetStartTime head.ReqHeadEx interface
func (*ReqHead) GetTimeOut ¶
GetTimeOut head.ReqHeadEx interface
func (*ReqHead) GetVersion ¶
GetVersion head.ReqHead interface
func (*ReqHead) SetTimeOut ¶
SetTimeOut head.ReqHeadEx 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"` //服务收到请求的时间 SpendTime int64 `json:"timesp,omitempty"` //从服务收到请求到响应完成,所花的时长 ServerTime int64 `json:"timesr,omitempty"` //服务器时间,M秒,用于检验对时 LogId string `json:"logid,omitempty"` }
func NewResHead ¶
Click to show internal directories.
Click to hide internal directories.