Documentation ¶
Index ¶
- func BuildArgs(options ...Option) []string
- type Option
- func IgnoreServerCert() Option
- func Silent() Option
- func VerboseOutput() Option
- func WithArgs(args []string) Option
- func WithBody(body string) Option
- func WithCaFile(caFile string) Option
- func WithConnectionTimeout(seconds int) Option
- func WithContentType(contentType string) Option
- func WithHeader(key, value string) Option
- func WithHeadersOnly() Option
- func WithHost(host string) Option
- func WithHostHeader(host string) Option
- func WithMethod(method string) Option
- func WithPath(path string) Option
- func WithPort(port int) Option
- func WithPostBody(body string) Option
- func WithQueryParameters(parameters map[string]string) Option
- func WithRetries(retry, retryDelay, retryMaxTime int) Option
- func WithRetryConnectionRefused(retryConnectionRefused bool) Option
- func WithScheme(scheme string) Option
- func WithSni(sni string) Option
- func WithoutRetries() Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildArgs ¶
BuildArgs accepts a set of curl.Option and generates the list of arguments that can be used to execute a curl request If multiple Option modify the same argument, the last defined one will win:
Example: BuildArgs(WithMethod("GET"), WithMethod("POST")) will return a curl with using a post method
A notable exception to this is the WithHeader option, which will always modify the map of headers used in the curl request.
Types ¶
type Option ¶
type Option func(config *requestConfig)
Option represents an option for a curl request.
func IgnoreServerCert ¶
func IgnoreServerCert() Option
IgnoreServerCert returns the Option to ignore the server certificate in the curl request https://curl.se/docs/manpage.html#-k
func Silent ¶
func Silent() Option
Silent returns the Option to enable silent mode for the curl request https://curl.se/docs/manpage.html#-s
func VerboseOutput ¶
func VerboseOutput() Option
VerboseOutput returns the Option to emit a verbose output for the curl request https://curl.se/docs/manpage.html#-v
func WithArgs ¶
WithArgs allows developers to append arbitrary args to the curl request This should mainly be used for debugging purposes. If there is an argument that the current Option set doesn't yet support, it should be added explicitly, to make it easier for developers to utilize
func WithBody ¶
WithBody returns the Option to configure the body for a curl request https://curl.se/docs/manpage.html#-d
func WithCaFile ¶
WithCaFile returns the Option to configure the certificate file used to verify the peer https://curl.se/docs/manpage.html#--cacert
func WithConnectionTimeout ¶
WithConnectionTimeout returns the Option to set a connection timeout on the curl request https://curl.se/docs/manpage.html#--connect-timeout https://curl.se/docs/manpage.html#-m
func WithContentType ¶
WithContentType returns the Option to configure the Content-Type header for the curl request
func WithHeader ¶
WithHeader returns the Option to configure a header for the curl request https://curl.se/docs/manpage.html#-H
func WithHeadersOnly ¶
func WithHeadersOnly() Option
WithHeadersOnly returns the Option to only return headers with the curl response https://curl.se/docs/manpage.html#-I
func WithHostHeader ¶
WithHostHeader returns the Option to configure the Host header for the curl request
func WithMethod ¶
WithMethod returns the Option to set the method for the curl request https://curl.se/docs/manpage.html#-X
func WithPath ¶
WithPath returns the Option to configure the path of the curl request The provided path is expected to not contain a leading `/`, so if it is provided, it will be trimmed
func WithPostBody ¶
WithPostBody returns the Option to configure a curl request to execute a post request with the provided json body
func WithQueryParameters ¶
WithQueryParameters returns the Option to configure the query parameters of the curl request
func WithRetries ¶
WithRetries returns the Option to configure the retries for the curl request https://curl.se/docs/manpage.html#--retry https://curl.se/docs/manpage.html#--retry-delay https://curl.se/docs/manpage.html#--retry-max-time
func WithRetryConnectionRefused ¶
WithRetryConnectionRefused returns the Option to configure the retry behavior for the curl request, when the connection is refused https://curl.se/docs/manpage.html#--retry-connrefused
func WithScheme ¶
WithScheme returns the Option to configure the scheme for the curl request
func WithSni ¶
WithSni returns the Option to configure a custom address to connect to https://curl.se/docs/manpage.html#--resolve
func WithoutRetries ¶
func WithoutRetries() Option
WithoutRetries returns the Option to disable retries for the curl request