Documentation
¶
Index ¶
- Constants
- func NewRangeError(from, to int64) string
- func StringValue(s String) string
- type BaseRequest
- type DataSize
- type EmptyResponse
- type EndpointNotFound
- type ErrorResponse
- type ErrorResponseWrapper
- type FieldError
- type HTTPClient
- type InvalidFieldReferenceError
- type JSONRequest
- type MultipartRequest
- type NotImplementedYet
- type Request
- type RequestError
- type RequestHandlerFunc
- type RequestValidationError
- type String
- type UnknownError
Constants ¶
const ( // ResponseReadError occurs when error happened while we tried to // read the response. ResponseReadError = "Error reading body" // ResponseReadBodyError occurs when error happened while we tried to // read the body of the response. ResponseReadBodyError = "Error reading body" // ErrorResponseParseError occurs when the response was an error, // but something went wrong with parsing it as an Error. ErrorResponseParseError = "Error response parse error" // UndefinedRequiredField occurs when a mandatory field is not defined // in a request. UndefinedRequiredField = "Undefined required field" // OutOfRangeError is a template error where a given value // has to be in a given range. OutOfRangeError = "Out of range [%d..%d]" // ExceedMaximumLengthError occurs when a parameter is longer // than expected on an endpoint. ExceedMaximumLengthError = "Value is too long" )
Variables ¶
This section is empty.
Functions ¶
func NewRangeError ¶
NewRangeError generates an error message for an OutOfRangeError.
func StringValue ¶
StringValue returns the value of a core.String as string. If the value is nil, it returns with an empty string.
Types ¶
type BaseRequest ¶
type BaseRequest interface {
Validate() error
}
BaseRequest is used to add simple functionality to all requests. Each request is responsible for its own validation by implementing this interface.
type DataSize ¶
type DataSize uint64
DataSize is an alias for uint64 with extra functions for easier conversion between sizes. The value should contain bytes.
I know I should use github.com/catalint/datasize or something similar, but I don't know if I want to support that later on or if I want to add extra functionality to it.
type EmptyResponse ¶
type EmptyResponse struct{}
EmptyResponse is an empty struct. The main reason behind this empty response is that there are endpoints where the return body is empty, but they have 2xx response code, therefore it was successful.
type EndpointNotFound ¶ added in v1.0.1
type EndpointNotFound struct {
Endpoint string
}
EndpointNotFound happens when the requested endpoint returs with 404 error code.
func (EndpointNotFound) Error ¶ added in v1.0.1
func (e EndpointNotFound) Error() string
type ErrorResponse ¶
type ErrorResponse struct { Message string `json:"message"` Code string `json:"code"` ID string `json:"id"` Kind string `json:"kind"` Info struct { Param string `json:"param"` Reason string `json:"reason"` } `json:"info"` }
ErrorResponse represents any kind of Error responses from Misskey.
type ErrorResponseWrapper ¶
type ErrorResponseWrapper struct {
Error json.RawMessage `json:"error"`
}
ErrorResponseWrapper is the wrapper for error responses.
type FieldError ¶
FieldError is the detailed error on a given field in a request.
type HTTPClient ¶ added in v1.0.1
HTTPClient is a simple intreface for http.Client.
type InvalidFieldReferenceError ¶
InvalidFieldReferenceError occurs when we couldn't determine the source of the error.
func (InvalidFieldReferenceError) Error ¶
func (e InvalidFieldReferenceError) Error() string
type JSONRequest ¶
type JSONRequest struct { Path string Request BaseRequest }
JSONRequest is the base request.
func (JSONRequest) EndpointPath ¶
func (r JSONRequest) EndpointPath() string
EndpointPath returns with the path for the endpoint.
type MultipartRequest ¶
type MultipartRequest struct { Path string Request BaseRequest }
MultipartRequest is the base multipart form request.
func (MultipartRequest) EndpointPath ¶
func (r MultipartRequest) EndpointPath() string
EndpointPath returns with the path for the endpoint.
type NotImplementedYet ¶
type NotImplementedYet struct {
Reason string
}
NotImplementedYet is an error for endpoint without implementation. The error will contain a reason for that, for example we don't know what is the response structure yet.
func (NotImplementedYet) Error ¶
func (e NotImplementedYet) Error() string
type Request ¶
type Request interface { ToBody(token string) (body []byte, contentType string, err error) EndpointPath() string Validate() error }
Request is the interface that has to be implemented to be valid request.
type RequestError ¶
RequestError happens when something went wrong with the request.
func (RequestError) Error ¶
func (e RequestError) Error() string
type RequestHandlerFunc ¶
RequestHandlerFunc is the function signature for request handlers called by services.
type RequestValidationError ¶
type RequestValidationError struct { Request BaseRequest Message string Field string }
RequestValidationError occurs when one or more mandatory fields are missing.
func (RequestValidationError) Error ¶
func (e RequestValidationError) Error() string
type UnknownError ¶
type UnknownError struct {
Response ErrorResponse
}
UnknownError occurs when we couldn't determine the source of the error.
func (UnknownError) Error ¶
func (e UnknownError) Error() string