Documentation
¶
Index ¶
Constants ¶
View Source
const UserAgent = "cored-openapi-sdk-go/" + Version
User-Agent
View Source
const Version = "0.28.108"
SDK version
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApiClient ¶
type ApiClient interface {
Preheat(ctx context.Context) error
Request(ctx context.Context, req *ApiRequest) (*ApiResponse, error)
OnEvent(eventType string, handler EventHandler)
OffEvent(eventType string, handler EventHandler)
Close() error
}
func NewDefaultApiClient ¶
type ApiError ¶
type ApiRequest ¶
type ApiRequest struct {
Method string `json:"method"`
Path string `json:"path"`
PathParams map[string]string `json:"path_params,omitempty"`
QueryParams map[string]string `json:"query_params,omitempty"`
HeaderParams map[string]string `json:"header_params,omitempty"`
Body interface{} `json:"body,omitempty"`
Stream io.Reader `json:"stream,omitempty"`
WithAppAccessToken bool `json:"with_app_access_token,omitempty"`
WithWebSocket bool `json:"with_websocket,omitempty"`
}
type ApiResponse ¶
type ApiResponse struct {
GetBody func() ([]byte, error)
// contains filtered or unexported fields
}
func (*ApiResponse) JSON ¶
func (e *ApiResponse) JSON(value interface{}) error
type Config ¶
type Config struct {
AppId string
AppSecret string
BackendUrl string
HttpClient HttpClient
ApiClient ApiClient
EnableEncryption bool
RequestTimeout time.Duration
TimeManager TimeManager
Logger Logger
JsonMarshal Marshaller
JsonUnmarshal Unmarshaller
}
type EventHandler ¶
type EventHandler func(ctx context.Context, header *EventHeader, body []byte) error
type EventHeader ¶
type HttpClient ¶
func NewDefaultHttpClient ¶
func NewDefaultHttpClient(requestTimeout time.Duration) HttpClient
type Logger ¶
type Logger interface {
Debugf(ctx context.Context, format string, args ...interface{})
Infof(ctx context.Context, format string, args ...interface{})
Warnf(ctx context.Context, format string, args ...interface{})
Errorf(ctx context.Context, format string, args ...interface{})
}
func NewDefaultLogger ¶
func NewDefaultLogger(level LoggerLevel) Logger
type LoggerLevel ¶
type LoggerLevel int8
const ( LoggerLevelDebug LoggerLevel = iota LoggerLevelInfo LoggerLevelWarn LoggerLevelError )
type Marshaller ¶
type TimeManager ¶
type TimeManager interface {
GetSystemTimestamp() int64
GetServerTimestamp() int64
SyncServerTimestamp(timestamp int64)
}
func NewDefaultTimeManager ¶
func NewDefaultTimeManager() TimeManager
type Unmarshaller ¶
Click to show internal directories.
Click to hide internal directories.