client

package
v6.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2026 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddQueryParam added in v6.4.0

func AddQueryParam(q url.Values, key string, value interface{})

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

func EncodePath(value string) string

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 GetDefaultClient

func GetDefaultClient(timeout time.Duration) (*http.Client, error)

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

func (client *Client) AddHeader(key string, value string)

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 *Client) FileUpload(url string, headers map[string]interface{}, params map[string]interface{}, paramName string, uploadId string) (*ClientResponse, error)

func (*Client) GetEndpoint

func (client *Client) GetEndpoint() string

GetEndpoint returns the client's current endpoint

func (*Client) GetHeaders

func (client *Client) GetHeaders() map[string]string

GetHeaders returns a copy of the client's current request headers

func (*Client) String

func (client *Client) String() string

type ClientOption

type ClientOption func(*Client) error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL