Documentation ¶
Overview ¶
Package ahttp 实现http client 上传数据. 授权方式为自动调用授权,可手动调用,也可以直接调用发送数据接口
Index ¶
Constants ¶
View Source
const ( CodeSuccess = 0 CodeUnknown = 10000 CodeParamException = 10001 CodeAuthFailed = 20000 CodeTokenExpired = 20001 // 需重新调用auth进行鉴权,获取token CodeTokenIsNull = 20002 // 需重新调用auth进行鉴权,获取token CodeTokenCheckFailed = 20003 // 根据token获取identify信息失败。需重新调用auth进行鉴权,获取token CodeUpdateSessionFailed = 20004 CodePublishMessageFailed = 30001 CodeRequestTooMany = 40000 )
错误码
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthRequest ¶
type AuthRequest struct { Version string `json:"version"` ClientID string `json:"clientId"` // 长度为64字符内,建议以MAC地址或SN码作为clientId. 目前productKey.deviceName SignMethod string `json:"signmethod"` Sign string `json:"sign"` ProductKey string `json:"productKey"` DeviceName string `json:"deviceName"` // 校验时间戳15分钟内的请求有效。时间戳格式为数值,单位ms // 值为自GMT 1970年1月1日0时0分到当前时间点所经过的毫秒数。 Timestamp int64 `json:"timestamp"` }
AuthRequest 鉴权请求
type AuthResponse ¶
type AuthResponse struct { Code int `json:"code"` Message string `json:"message"` Info struct { Token string `json:"token"` } `json:"info"` }
AuthResponse 鉴权回复
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 客户端
func New ¶
New 新建alink http client 默认加签算法: hmacmd5 默认host: https://iot-as-http.cn-shanghai.aliyuncs.com 默认使用 http.DefaultClient
type DataResponse ¶
type DataResponse struct { Code int `json:"code"` Message string `json:"message"` Info struct { MessageID int64 `json:"messageID"` } `json:"info"` }
DataResponse 上报数据回复
type Option ¶
type Option func(c *Client)
Option client option
func WithHTTPClient ¶
WithHTTPClient with custom http.Client
func WithSignMethod ¶
WithSignMethod 设置签名方法,目前支持hmacsha1,hmacmd5(默认)
Click to show internal directories.
Click to hide internal directories.