Documentation
¶
Index ¶
- type Builder
- func (b *Builder) BuildURL() (string, error)
- func (b *Builder) Exec() error
- func (b *Builder) GetBody() (string, error)
- func (b *Builder) GetContext() context.Context
- func (b *Builder) GetHeaders() map[string]string
- func (b *Builder) GetMethod() string
- func (b *Builder) GetOutput() string
- func (b *Builder) GetTimeout() time.Duration
- func (b *Builder) GetUrl() string
- func (b *Builder) IgnoreStatusCode() *Builder
- func (b *Builder) IsIgnoreStatusCode() bool
- func (b *Builder) SetBody(body any) *Builder
- func (b *Builder) SetContext(ctx context.Context) *Builder
- func (b *Builder) SetHeader(key string, value string) *Builder
- func (b *Builder) SetHeaders(headers map[string]string) *Builder
- func (b *Builder) SetMethod(method string) *Builder
- func (b *Builder) SetOutput(output string) *Builder
- func (b *Builder) SetQueryParam(key, value string) *Builder
- func (b *Builder) SetQueryParams(params map[string]string) *Builder
- func (b *Builder) SetTimeout(duration time.Duration) *Builder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func (*Builder) BuildURL ¶
BuildURL constructs and returns the final URL with all query parameters applied.
func (*Builder) GetContext ¶
GetContext returns the context associated with the request.
func (*Builder) GetHeaders ¶
GetHeaders returns the headers set for the request.
func (*Builder) GetTimeout ¶
GetTimeout returns the timeout duration set for the request.
func (*Builder) IgnoreStatusCode ¶
IgnoreStatusCode allows responses with non-2xx status codes to be processed without error.
func (*Builder) IsIgnoreStatusCode ¶
IsIgnoreStatusCode returns whether the request should ignore non-2xx status codes.
func (*Builder) SetBody ¶
SetBody sets the request body.
If the input is a string, it's used as-is. If the input is a byte slice, it's wrapped in a reader. If the input is any other type, it's serialized to JSON.
Automatically sets the "Content-Type" header to "application/json" if JSON encoding is used.
func (*Builder) SetContext ¶
SetContext allows setting a custom context for the request.
This is useful for handling request cancellation and deadlines.
func (*Builder) SetHeaders ¶
SetHeaders adds or updates multiple HTTP headers in the request.
func (*Builder) SetMethod ¶
SetMethod specifies the HTTP method for the request.
Supported methods: "GET", "POST", "PUT", "PATCH".
func (*Builder) SetOutput ¶
SetOutput defines the file path or directory where the downloaded content will be saved.
func (*Builder) SetQueryParam ¶
SetQueryParam adds a single query parameter to the URL.
func (*Builder) SetQueryParams ¶
SetQueryParams adds multiple query parameters to the URL.