Documentation
¶
Index ¶
- func GET[Res any](ctx context.Context, url string, opts ...HTTPConfigOptions) (*Res, error)
- func POST[Req, Res any](ctx context.Context, url string, req *Req, opts ...HTTPConfigOptions) (*Res, error)
- func POSTFormData[Res any](ctx context.Context, url string, opts ...HTTPConfigOptions) (*Res, error)
- func POSTMultiPartFormData[Res any](ctx context.Context, url string, files map[string]string, ...) (*Res, error)
- func PUT[Req, Res any](ctx context.Context, url string, req *Req, opts ...HTTPConfigOptions) (*Res, error)
- type HTTPConfig
- type HTTPConfigOptions
- func WithCircuitBreaker(c *gobreaker.CircuitBreaker[any]) HTTPConfigOptions
- func WithFormParams(c netUrl.Values) HTTPConfigOptions
- func WithHeaders(c http.Header) HTTPConfigOptions
- func WithHttpClient(c *httpClient.HTTPClient) HTTPConfigOptions
- func WithMultiPartFormParams(c map[string]string) HTTPConfigOptions
- func WithQueryParams(c netUrl.Values) HTTPConfigOptions
- func WithTimeout(t time.Duration) HTTPConfigOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func POST ¶
func POST[Req, Res any](ctx context.Context, url string, req *Req, opts ...HTTPConfigOptions) (*Res, error)
POST http method with Req as request type and Res as response type
func POSTFormData ¶
func POSTFormData[Res any](ctx context.Context, url string, opts ...HTTPConfigOptions) (*Res, error)
POSTFormData with Res as response type and allows application/x-www-form-urlencoded -> formData
func POSTMultiPartFormData ¶
func POSTMultiPartFormData[Res any](ctx context.Context, url string, files map[string]string, opts ...HTTPConfigOptions) (*Res, error)
POSTMultiPartFormData with Res as response type, map of files with key as fieldName and value as filePath
Types ¶
type HTTPConfig ¶
type HTTPConfig struct { HttpClient *httpClient.HTTPClient Timeout time.Duration Headers http.Header QueryParams netUrl.Values FormParams netUrl.Values MultipartFormParams map[string]string CircuitBreaker *gobreaker.CircuitBreaker[any] // currently only github.com/sony/gobreaker/v2 is supported }
HTTPConfig different http configurations
type HTTPConfigOptions ¶
type HTTPConfigOptions func(*HTTPConfig)
func WithCircuitBreaker ¶
func WithCircuitBreaker(c *gobreaker.CircuitBreaker[any]) HTTPConfigOptions
func WithFormParams ¶
func WithFormParams(c netUrl.Values) HTTPConfigOptions
func WithHeaders ¶
func WithHeaders(c http.Header) HTTPConfigOptions
func WithHttpClient ¶
func WithHttpClient(c *httpClient.HTTPClient) HTTPConfigOptions
func WithMultiPartFormParams ¶
func WithMultiPartFormParams(c map[string]string) HTTPConfigOptions
func WithQueryParams ¶
func WithQueryParams(c netUrl.Values) HTTPConfigOptions
func WithTimeout ¶
func WithTimeout(t time.Duration) HTTPConfigOptions
Click to show internal directories.
Click to hide internal directories.