Documentation
¶
Index ¶
- func IsBadRequest(err error) bool
- func IsNotFound(err error) bool
- func IsServerError(err error) bool
- func IsUnauthorized(err error) bool
- type Client
- func (c *Client) Delete(ctx context.Context, path string) error
- func (c *Client) Get(ctx context.Context, path string, result interface{}) error
- func (c *Client) GetVersion(ctx context.Context) (string, error)
- func (c *Client) Patch(ctx context.Context, path string, body, result interface{}) error
- func (c *Client) Post(ctx context.Context, path string, body, result interface{}) error
- func (c *Client) PostMultipart(ctx context.Context, path string, fields map[string]string, file MultipartFile, ...) error
- func (c *Client) PostOnce(ctx context.Context, path string, body, result interface{}) error
- func (c *Client) Put(ctx context.Context, path string, body, result interface{}) error
- type Error
- type MultipartFile
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsBadRequest ¶
IsBadRequest checks if the error is a 400 Bad Request error
func IsNotFound ¶
IsNotFound checks if the error is a 404 Not Found error
func IsServerError ¶
IsServerError checks if the error is a 5xx server error
func IsUnauthorized ¶
IsUnauthorized checks if the error is a 401 or 403 error
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the HTTP client for Coolify API
func (*Client) GetVersion ¶
GetVersion fetches the API version
func (*Client) PostMultipart ¶ added in v1.10.0
func (c *Client) PostMultipart(ctx context.Context, path string, fields map[string]string, file MultipartFile, result interface{}) error
PostMultipart makes a multipart/form-data POST request to the API. Fields are written as plain form fields before the file part. The file content is streamed, never buffered in memory.
type Error ¶
type Error struct {
StatusCode int
Message string
Path string
// Body is the raw response body, kept for callers that need structured
// error details beyond Message (for example validation errors).
Body []byte
// RetryAfter is the Retry-After response header, if present.
RetryAfter string
}
Error represents an API error response
type MultipartFile ¶ added in v1.10.0
type MultipartFile struct {
// FieldName is the form field name of the file part (e.g. "file").
FieldName string
// FileName is the client file name sent with the part.
FileName string
// Content is streamed into the request body. When it implements
// io.Seeker, failed requests are retried from the start of Content.
Content io.Reader
// Size is the number of bytes Content yields. When >= 0 the request
// carries an exact Content-Length; when < 0 it is sent chunked.
Size int64
}
MultipartFile is the file part of a multipart/form-data request.
type Option ¶
type Option func(*Client)
Option configures the API client
func WithHTTPClient ¶
WithHTTPClient sets a custom HTTP client
func WithRetries ¶
WithRetries sets the number of retries for failed requests
func WithTimeout ¶
WithTimeout sets the request timeout