Documentation ¶
Index ¶
- Constants
- Variables
- func EncodeMultipartFormData(payload MultipartPayload) ([]byte, string, error)
- func RegisterHook(hook func(string, *http.Request))
- func RegisterPostRequestHook(hook func(*http.Response, []byte))
- func RegisterPreRequestHook(hook func(string, *http.Request))
- type ApiV8Error
- type Attachment
- type ContentType
- type Endpoint
- type FieldError
- type File
- type MultipartPayload
- type OAuthError
- type RequestType
- type ResponseWithContent
- type RestError
Constants ¶
View Source
const ( BaseUrl = "https://discord.com/api/v10" AuditLogReasonHeader = "X-Audit-Log-Reason" )
Variables ¶
View Source
var Client = http.Client{ Transport: &http.Transport{ TLSHandshakeTimeout: time.Second * 3, }, Timeout: time.Second * 3, }
TODO: Allow users to specify custom timeouts
Functions ¶
func EncodeMultipartFormData ¶
func EncodeMultipartFormData(payload MultipartPayload) ([]byte, string, error)
func RegisterHook ¶
func RegisterPostRequestHook ¶
func RegisterPreRequestHook ¶
Types ¶
type ApiV8Error ¶
type ApiV8Error struct { Code int Errors []FieldError Message string }
func (*ApiV8Error) FirstErrorCode ¶
func (e *ApiV8Error) FirstErrorCode() interface{}
func (*ApiV8Error) UnmarshalJSON ¶
func (e *ApiV8Error) UnmarshalJSON(data []byte) error
type Attachment ¶
type ContentType ¶
type ContentType string
const ( ApplicationJson ContentType = "application/json" ApplicationFormUrlEncoded ContentType = "application/x-www-form-urlencoded" MultipartFormData ContentType = "multipart/form-data" ImageJpeg ContentType = "image/jpeg" ImagePng ContentType = "image/png" ImageGif ContentType = "image/gif" Nil ContentType = "" )
type Endpoint ¶
type Endpoint struct { RequestType RequestType ContentType ContentType Endpoint string Route ratelimit.Route RateLimiter *ratelimit.Ratelimiter AdditionalHeaders map[string]string }
type FieldError ¶
type FieldError struct { FieldName string `json:"-"` Code interface{} `json:"code"` // Can be int or string Message string `json:"message"` }
func (FieldError) Error ¶
func (e FieldError) Error() string
type MultipartPayload ¶
type MultipartPayload interface {
GetAttachments() []Attachment
}
type OAuthError ¶
type OAuthError struct { ErrorCode string `json:"error"` ErrorDescription string `json:"error_description"` }
func (OAuthError) Error ¶
func (e OAuthError) Error() string
type RequestType ¶
type RequestType string
const ( GET RequestType = "GET" POST RequestType = "POST" PATCH RequestType = "PATCH" PUT RequestType = "PUT" DELETE RequestType = "DELETE" )
type ResponseWithContent ¶
type RestError ¶
type RestError struct { StatusCode int ApiError ApiV8Error Url string Raw []byte }
func (*RestError) IsClientError ¶
func (*RestError) IsServerError ¶
Click to show internal directories.
Click to hide internal directories.