Documentation
¶
Index ¶
- func AddQueryParam(q url.Values, key string, value interface{})
- func EncodePath(value string) string
- func GetDefaultClient(timeout time.Duration) (*http.Client, error)
- func ResponseBody(resp *ClientResponse) ([]byte, error)
- type AppwriteError
- type Client
- func (client *Client) AddHeader(key string, value string)
- func (client *Client) Call(method string, path string, headers map[string]interface{}, ...) (*ClientResponse, error)
- func (client *Client) FileUpload(url string, headers map[string]interface{}, params map[string]interface{}, ...) (*ClientResponse, error)
- func (client *Client) GetEndpoint() string
- func (client *Client) GetHeaders() map[string]string
- func (client *Client) String() string
- type ClientOption
- type ClientResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddQueryParam ¶ added in v6.4.0
AddQueryParam writes one query parameter into q.
Arrays and slices are indexed -- `key[0]`, `key[1]`. The API also accepts a bare repeated `key[]`, so either reaches the server; indexed keys are what the API documents.
Both the GET branch of Call and the URL-returning service methods go through here, so the two cannot disagree on the encoding.
func EncodePath ¶ added in v6.4.0
EncodePath percent-encodes one path segment.
Everything outside the RFC 2396 unreserved set -- alphanumerics and -_.!~*'() -- is escaped, so a value is confined to the single segment it was substituted into.
Not url.PathEscape: that leaves the sub-delimiters legal in a path segment alone, so an id containing `&` or `=` passes through unescaped and the request reaches a different route than the one asked for.
Iteration is over bytes, not runes: every byte of a multi-byte character fails the unreserved test and is emitted as %XX, which is how UTF-8 is percent- encoded -- `é` becomes %C3%A9. A rune-wise loop would emit %E9 and be wrong.
func ResponseBody ¶ added in v6.5.0
func ResponseBody(resp *ClientResponse) ([]byte, error)
ResponseBody returns the raw response body bytes.
Types ¶
type AppwriteError ¶
type AppwriteError struct {
// contains filtered or unexported fields
}
AppwriteError represents an error of a client request
func (*AppwriteError) Error ¶
func (ce *AppwriteError) Error() string
func (*AppwriteError) GetMessage ¶
func (ce *AppwriteError) GetMessage() string
func (*AppwriteError) GetResponse ¶
func (ce *AppwriteError) GetResponse() string
func (*AppwriteError) GetStatusCode ¶
func (ce *AppwriteError) GetStatusCode() int
type Client ¶
type Client struct {
Client *http.Client
Headers map[string]string
Config map[string]string
Endpoint string
Timeout time.Duration
SelfSigned bool
ChunkSize int64
}
Client is the client struct to access Appwrite services
func New ¶
func New(optionalSetters ...ClientOption) Client
Initialize a new Appwrite client with a given timeout
func (*Client) AddHeader ¶
AddHeader add a new custom header that the Client should send on each request
func (*Client) Call ¶
func (client *Client) Call(method string, path string, headers map[string]interface{}, params map[string]interface{}) (*ClientResponse, error)
Call an API using Client
func (*Client) FileUpload ¶
func (*Client) GetEndpoint ¶
GetEndpoint returns the client's current endpoint
func (*Client) GetHeaders ¶
GetHeaders returns a copy of the client's current request headers
type ClientOption ¶
type ClientResponse ¶
type ClientResponse struct {
Status string
StatusCode int
Header http.Header
// Result holds the raw response body as []byte, for a JSON response and a
// non-JSON one alike. It carried a string for JSON responses until v6.5.0,
// so a `Result.(string)` assertion that used to succeed now fails, and an
// unchecked one panics. Read it through ResponseBody, which accepts either
// and so keeps working across the change.
Result interface{}
Type string
}
ClientResponse - represents the client response