Documentation
¶
Index ¶
- func MustInt(n json.Number) int
- type BasicResp
- type Boolean
- type FloatNumner
- type IntNumber
- type JsonApiSpec
- func (s *JsonApiSpec) EnableCrypto()
- func (s *JsonApiSpec[D, R]) FormSet(key, value string)
- func (s *JsonApiSpec[D, R]) FormSetAll(params map[string]string)
- func (s *JsonApiSpec[D, R]) FormSetInt(key string, value int)
- func (s *JsonApiSpec[D, R]) FormSetInt64(key string, value int64)
- func (s *JsonApiSpec[D, R]) Init(baseUrl string)
- func (s *JsonApiSpec) IsCrypto() bool
- func (s *JsonApiSpec[D, R]) Parse(r io.Reader) (err error)
- func (s *JsonApiSpec[D, R]) Payload() protocol.Payload
- func (s *JsonApiSpec) QueryGet(key string) string
- func (s *JsonApiSpec) QuerySet(key, value string)
- func (s *JsonApiSpec) QuerySetInt(key string, value int)
- func (s *JsonApiSpec) QuerySetInt64(key string, value int64)
- func (s *JsonApiSpec) QuerySetNow(key string)
- func (s *JsonApiSpec) SetBaseUrl(baseUrl string)
- func (s *JsonApiSpec) SetCryptoKey(key string)
- func (s *JsonApiSpec) Url() string
- type JsonpApiSpec
- func (s *JsonpApiSpec) EnableCrypto()
- func (s *JsonpApiSpec[D, R]) Init(baseUrl, cb string)
- func (s *JsonpApiSpec) IsCrypto() bool
- func (s *JsonpApiSpec[D, R]) Parse(r io.Reader) (err error)
- func (s *JsonpApiSpec[D, R]) Payload() protocol.Payload
- func (s *JsonpApiSpec) QueryGet(key string) string
- func (s *JsonpApiSpec) QuerySet(key, value string)
- func (s *JsonpApiSpec) QuerySetInt(key string, value int)
- func (s *JsonpApiSpec) QuerySetInt64(key string, value int64)
- func (s *JsonpApiSpec) QuerySetNow(key string)
- func (s *JsonpApiSpec) SetBaseUrl(baseUrl string)
- func (s *JsonpApiSpec) SetCryptoKey(key string)
- func (s *JsonpApiSpec) Url() string
- type M115ApiSpec
- func (s *M115ApiSpec) EnableCrypto()
- func (s *M115ApiSpec[D]) Init(baseUrl string, ex M115Extractor[D])
- func (s *M115ApiSpec) IsCrypto() bool
- func (s *M115ApiSpec[D]) ParamSet(key, value string)
- func (s *M115ApiSpec[D]) ParamSetAll(params map[string]string)
- func (s *M115ApiSpec[D]) Parse(r io.Reader) (err error)
- func (s *M115ApiSpec[D]) Payload() protocol.Payload
- func (s *M115ApiSpec) QueryGet(key string) string
- func (s *M115ApiSpec) QuerySet(key, value string)
- func (s *M115ApiSpec) QuerySetInt(key string, value int)
- func (s *M115ApiSpec) QuerySetInt64(key string, value int64)
- func (s *M115ApiSpec) QuerySetNow(key string)
- func (s *M115ApiSpec) SetBaseUrl(baseUrl string)
- func (s *M115ApiSpec) SetCryptoKey(key string)
- func (s *M115ApiSpec) Url() string
- type M115Extractor
- type PayloadImpl
- type StandardResp
- type VoidResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BasicResp ¶
type BasicResp struct {
// Response state
State bool `json:"state"`
// Possible error code fields
ErrorCode IntNumber `json:"errno,omitempty"`
ErrorCode2 int `json:"errNo,omitempty"`
ErrorCode3 int `json:"errcode,omitempty"`
ErrorCode4 int `json:"errCode,omitempty"`
ErrorCode5 int `json:"code,omitempty"`
// Possible error message fields
ErrorMessage string `json:"error,omitempty"`
ErrorMessage2 string `json:"message,omitempty"`
ErrorMessage3 string `json:"error_msg,omitempty"`
}
BasicResp is the basic response for most JSON/JSONP API.
type FloatNumner ¶
type FloatNumner float64
FloatNumner uses for JSON field which maybe a string or an float number.
func (FloatNumner) Float64 ¶
func (n FloatNumner) Float64() float64
func (*FloatNumner) UnmarshalJSON ¶
func (n *FloatNumner) UnmarshalJSON(b []byte) (err error)
type IntNumber ¶
type IntNumber int64
IntNumber uses for JSON field which maybe a string or an integer number.
func (*IntNumber) UnmarshalJSON ¶
type JsonApiSpec ¶
type JsonApiSpec[D, R any] struct { // The API result, its value will be filled after |Parse| called. Result D // contains filtered or unexported fields }
JsonApiSpec is the base spec for all JSON ApiSpec.
Type parameters:
- D: Result type.
- R: Response type.
func (*JsonApiSpec) EnableCrypto ¶
func (s *JsonApiSpec) EnableCrypto()
func (*JsonApiSpec[D, R]) FormSet ¶
func (s *JsonApiSpec[D, R]) FormSet(key, value string)
func (*JsonApiSpec[D, R]) FormSetAll ¶
func (s *JsonApiSpec[D, R]) FormSetAll(params map[string]string)
func (*JsonApiSpec[D, R]) FormSetInt ¶
func (s *JsonApiSpec[D, R]) FormSetInt(key string, value int)
func (*JsonApiSpec[D, R]) FormSetInt64 ¶
func (s *JsonApiSpec[D, R]) FormSetInt64(key string, value int64)
func (*JsonApiSpec[D, R]) Init ¶
func (s *JsonApiSpec[D, R]) Init(baseUrl string)
func (*JsonApiSpec[D, R]) Payload ¶
func (s *JsonApiSpec[D, R]) Payload() protocol.Payload
func (*JsonApiSpec) QuerySetInt ¶
func (*JsonApiSpec) QuerySetInt64 ¶
func (*JsonApiSpec) QuerySetNow ¶
func (s *JsonApiSpec) QuerySetNow(key string)
func (*JsonApiSpec) SetBaseUrl ¶
func (s *JsonApiSpec) SetBaseUrl(baseUrl string)
func (*JsonApiSpec) SetCryptoKey ¶
func (s *JsonApiSpec) SetCryptoKey(key string)
type JsonpApiSpec ¶
type JsonpApiSpec[D, R any] struct { // The API result, its value will be filled after |Parse| called. Result D // contains filtered or unexported fields }
JsonpApiSpec is the base spec for all JSON-P ApiSpec.
Type parameters:
- D: Result type.
- R: Response type.
func (*JsonpApiSpec) EnableCrypto ¶
func (s *JsonpApiSpec) EnableCrypto()
func (*JsonpApiSpec[D, R]) Init ¶
func (s *JsonpApiSpec[D, R]) Init(baseUrl, cb string)
func (*JsonpApiSpec[D, R]) Payload ¶
func (s *JsonpApiSpec[D, R]) Payload() protocol.Payload
func (*JsonpApiSpec) QuerySetInt ¶
func (*JsonpApiSpec) QuerySetInt64 ¶
func (*JsonpApiSpec) QuerySetNow ¶
func (s *JsonpApiSpec) QuerySetNow(key string)
func (*JsonpApiSpec) SetBaseUrl ¶
func (s *JsonpApiSpec) SetBaseUrl(baseUrl string)
func (*JsonpApiSpec) SetCryptoKey ¶
func (s *JsonpApiSpec) SetCryptoKey(key string)
type M115ApiSpec ¶
type M115ApiSpec[D any] struct { // Final result. Result D // contains filtered or unexported fields }
M115ApiSpec is the base struct for all m115 ApiSpec.
func (*M115ApiSpec) EnableCrypto ¶
func (s *M115ApiSpec) EnableCrypto()
func (*M115ApiSpec[D]) Init ¶
func (s *M115ApiSpec[D]) Init(baseUrl string, ex M115Extractor[D])
func (*M115ApiSpec[D]) ParamSet ¶
func (s *M115ApiSpec[D]) ParamSet(key, value string)
func (*M115ApiSpec[D]) ParamSetAll ¶
func (s *M115ApiSpec[D]) ParamSetAll(params map[string]string)
func (*M115ApiSpec[D]) Parse ¶
func (s *M115ApiSpec[D]) Parse(r io.Reader) (err error)
Parse implements |ApiSpec.Parse|.
func (*M115ApiSpec[D]) Payload ¶
func (s *M115ApiSpec[D]) Payload() protocol.Payload
Payload implements |ApiSpec.Payload|.
func (*M115ApiSpec) QuerySetInt ¶
func (*M115ApiSpec) QuerySetInt64 ¶
func (*M115ApiSpec) QuerySetNow ¶
func (s *M115ApiSpec) QuerySetNow(key string)
func (*M115ApiSpec) SetBaseUrl ¶
func (s *M115ApiSpec) SetBaseUrl(baseUrl string)
func (*M115ApiSpec) SetCryptoKey ¶
func (s *M115ApiSpec) SetCryptoKey(key string)
type M115Extractor ¶
type PayloadImpl ¶
type PayloadImpl struct {
// contains filtered or unexported fields
}
func (*PayloadImpl) ContentLength ¶
func (pi *PayloadImpl) ContentLength() int64
func (*PayloadImpl) ContentType ¶
func (pi *PayloadImpl) ContentType() string
type StandardResp ¶
type StandardResp struct {
BasicResp
Data json.RawMessage `json:"data"`
}
func (*StandardResp) Extract ¶
func (r *StandardResp) Extract(v any) error
type VoidResult ¶
type VoidResult struct{}
VoidResult can be used as result type parameter in ApiSpec, when we do not care about result data from API.
Click to show internal directories.
Click to hide internal directories.