curl

package
v1.0.0-waypoint-prereq Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildArgs

func BuildArgs(options ...Option) []string

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

func WithArgs(args []string) Option

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

func WithBody(body string) Option

WithBody returns the Option to configure the body for a curl request https://curl.se/docs/manpage.html#-d

func WithCaFile

func WithCaFile(caFile string) Option

WithCaFile returns the Option to configure the certificate file used to verify the peer https://curl.se/docs/manpage.html#--cacert

func WithConnectionTimeout

func WithConnectionTimeout(seconds int) Option

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

func WithContentType(contentType string) Option

WithContentType returns the Option to configure the Content-Type header for the curl request

func WithHeader

func WithHeader(key, value string) Option

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 WithHost

func WithHost(host string) Option

WithHost returns the Option to set the host for the curl request

func WithHostHeader

func WithHostHeader(host string) Option

WithHostHeader returns the Option to configure the Host header for the curl request

func WithHostPort

func WithHostPort(hostPort string) Option

WithHostPort returns the Option to set the host and port for the curl request The provided string is assumed to have the format [HOST]:[PORT]

func WithMethod

func WithMethod(method string) Option

WithMethod returns the Option to set the method for the curl request https://curl.se/docs/manpage.html#-X

func WithPath

func WithPath(path string) Option

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 WithPort

func WithPort(port int) Option

WithPort returns the Option to set the port for the curl request

func WithPostBody

func WithPostBody(body string) Option

WithPostBody returns the Option to configure a curl request to execute a post request with the provided json body

func WithQueryParameters

func WithQueryParameters(parameters map[string]string) Option

WithQueryParameters returns the Option to configure the query parameters of the curl request

func WithRetries

func WithRetries(retry, retryDelay, retryMaxTime int) Option

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

func WithRetryConnectionRefused(retryConnectionRefused bool) Option

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

func WithScheme(scheme string) Option

WithScheme returns the Option to configure the scheme for the curl request

func WithSni

func WithSni(sni string) Option

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

Jump to

Keyboard shortcuts

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