Documentation
¶
Index ¶
- Variables
- type Client
- func (c *Client) Create(payload any) (*Resp, error)
- func (c *Client) CreateMany(payload any) (*Resp, error)
- func (c *Client) Delete(id string) (*Resp, error)
- func (c *Client) DeleteMany(payload any) (*Resp, error)
- func (c *Client) Get(id string, dst any) (*Resp, error)
- func (c *Client) List(items any, total *int64) (*Resp, error)
- func (c *Client) Patch(id string, payload any) (*Resp, error)
- func (c *Client) PatchMany(payload any) (*Resp, error)
- func (c *Client) QueryString() (string, error)
- func (c *Client) RequestURL() (string, error)
- func (c *Client) Update(id string, payload any) (*Resp, error)
- func (c *Client) UpdateMany(payload any) (*Resp, error)
- type Option
- func WithBaseAuth(username, password string) Option
- func WithContext(ctx context.Context) Option
- func WithDebug() Option
- func WithHTTPClient(client *http.Client) Option
- func WithHeader(header http.Header) Option
- func WithLogger(logger types.Logger) Option
- func WithQuery(_keyValues ...any) Option
- func WithQueryExpand(expand string, depth uint) Option
- func WithQueryFuzzy(fuzzy bool) Option
- func WithQueryIndex(index string) Option
- func WithQueryNocache(nocache bool) Option
- func WithQueryOr(or bool) Option
- func WithQueryPagination(page, size uint) Option
- func WithQuerySelect(selects ...string) Option
- func WithQuerySortby(sortby string) Option
- func WithQueryTimeRange(columeName string, start, end time.Time) Option
- func WithRateLimit(r rate.Limit, b int) Option
- func WithRetry(maxRetries int, wait time.Duration) Option
- func WithTimeout(timeout time.Duration) Option
- func WithToken(token string) Option
- func WithUserAgent(userAgent string) Option
- type Resp
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotStringSlice = errors.New("payload must be a string slice") ErrNotStructSlice = errors.New("payload must be a struct slice") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
func New ¶
New creates a new client instance with given base URL and options. The base URL must start with "http://" or "https://".
func (*Client) Create ¶
Create send a POST request to create a new resource. payload can be []byte or struct/pointer that can be marshaled to JSON.
func (*Client) CreateMany ¶
CreateMany send a POST request to batch create multiple resources. payload should be a struct slice, eg: []User or []*User
func (*Client) DeleteMany ¶
DeleteMany send a DELETE request to batch delete multiple resources. payload should be a string slice contains id list.
func (*Client) Get ¶
Get send a GET request to get one resource by given id. The id parameter specifies which resource to retrieve. The dst parameter must be a pointer to struct where the resource will be unmarshaled into.
func (*Client) List ¶
List send a GET request to retrieve a list of resources. items must be a pointer to slice where items will be unmarshaled into. total will be set to the total number of items available.
func (*Client) PatchMany ¶
PatchMany send a PATCH request to batch partially update multiple resources. payload should be a struct slice, eg: []User or []*User
func (*Client) QueryString ¶
QueryString build the query string from structured query parameters and raw query string.
func (*Client) RequestURL ¶
RequestURL constructs the full request URL including base URL and query parameters.
type Option ¶
type Option func(*Client)