Documentation ¶
Index ¶
- Constants
- Variables
- 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 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"} DkUseFileName = Key{"UseFileName", "is true/false"} DkUid = Key{"uid", "http: param 'uid'"} DkBiz = Key{"biz", "http: param 'biz' for file upload"} DkType = Key{"type", "http: param 'type' for file upload"} DkName = Key{"name", "http: param 'name' for file upload"} DkSize = Key{"size", "http: param 'size' for file upload"} DkId = Key{"id", "http: param 'id'"} //为分片上传 DkKey = Key{"key", "http: param 'key' for file upload"} DkChunkNum = Key{"chunknum", "http: param 'chunknum' for file upload"} DkChunkOffset = Key{"chunkoffset", "http: param 'chunkoffset' for file upload"} DkChunkSize = Key{"chunksize", "http: param 'chunksize' for file upload"} )
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 ¶
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"` StartT 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"` StartT int64 `json:"timeAt,omitempty"` SpendT int64 `json:"timeSp,omitempty"` //从服务收到请求到响应完成,所花的时长 SrTime int64 `json:"timeSr,omitempty"` //服务器时间,M秒,用于检验对时 }
{ "version": "", "source": "", "seqid":"",
"result":{ "errno": 0, "error": "", "data":{} } }
func NewResHead ¶
Click to show internal directories.
Click to hide internal directories.