Documentation
¶
Index ¶
- func BodyBytes(ctx context.Context, response *http.Response) ([]byte, error)
- func Fetch[T interface{}](ctx context.Context, url, method string, payload interface{}, ...) (T, error)
- func FetchData(ctx context.Context, apiURL, method, stage string, headers *http.Header, ...) (string, error)
- func FetchRaw(ctx context.Context, uri, method string, payload interface{}, ...) (*http.Response, error)
- func GetPublicIP(proxy *Proxy) (string, error)
- func JsonBody[T interface{}](ctx context.Context, response *http.Response) (T, error)
- func TextBody(ctx context.Context, response *http.Response) (string, error)
- type Client
- type FetchOptions
- type HttpxResponse
- func GetRequest(ctx context.Context, url string, headers map[string]string, proxyURL string, ...) (*HttpxResponse, error)
- func GetRequestWithCookieJar(ctx context.Context, url string, headers map[string]string, proxyURL string, ...) (*HttpxResponse, error)
- func PostRequest(ctx context.Context, url string, body []byte, headers map[string]string, ...) (*HttpxResponse, error)
- func PostRequestWithCookieJar(ctx context.Context, url string, body []byte, headers map[string]string, ...) (*HttpxResponse, error)
- func Request(ctx context.Context, method, url string, body []byte, ...) (*HttpxResponse, error)
- func RequestWithCookieJar(ctx context.Context, method, url string, body []byte, ...) (*HttpxResponse, error)
- type Proxy
- type RequestOptions
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fetch ¶
func Fetch[T interface{}](ctx context.Context, url, method string, payload interface{}, options ...FetchOptions) (T, error)
func GetPublicIP ¶ added in v1.8.10
GetPublicIP returns the service's public-facing IP address by querying external IP detection services This is useful when the service is behind NAT and you need the internet-visible IP address
Types ¶
type Client ¶ added in v1.2.0
type Client struct {
// contains filtered or unexported fields
}
Client is a custom HTTP client that can extract proxy information
type FetchOptions ¶
type HttpxResponse ¶ added in v1.2.0
type HttpxResponse struct {
StatusCode int
Headers http.Header
Body []byte
ProxyIP string // X-Proxy-IP header from CONNECT response, empty if no proxy used
}
HttpxResponse represents the response from an HTTP request
func GetRequest ¶ added in v1.2.0
func GetRequest(ctx context.Context, url string, headers map[string]string, proxyURL string, timeout time.Duration) (*HttpxResponse, error)
GetRequest performs a GET request and returns an HttpxResponse
func GetRequestWithCookieJar ¶ added in v1.2.0
func GetRequestWithCookieJar(ctx context.Context, url string, headers map[string]string, proxyURL string, timeout time.Duration, cookieJar *cookiejar.Jar) (*HttpxResponse, error)
GetRequestWithCookieJar performs a GET request with cookie jar support and returns an HttpxResponse
func PostRequest ¶ added in v1.2.0
func PostRequest(ctx context.Context, url string, body []byte, headers map[string]string, proxyURL string, timeout time.Duration) (*HttpxResponse, error)
PostRequest performs a POST request and returns an HttpxResponse
func PostRequestWithCookieJar ¶ added in v1.2.0
func PostRequestWithCookieJar(ctx context.Context, url string, body []byte, headers map[string]string, proxyURL string, timeout time.Duration, cookieJar *cookiejar.Jar) (*HttpxResponse, error)
PostRequestWithCookieJar performs a POST request with cookie jar support and returns an HttpxResponse
func Request ¶ added in v1.2.0
func Request(ctx context.Context, method, url string, body []byte, headers map[string]string, proxyURL string, timeout time.Duration) (*HttpxResponse, error)
Request performs an HTTP request and returns an HttpxResponse
func RequestWithCookieJar ¶ added in v1.2.0
func RequestWithCookieJar(ctx context.Context, method, url string, body []byte, headers map[string]string, proxyURL string, timeout time.Duration, cookieJar *cookiejar.Jar) (*HttpxResponse, error)
RequestWithCookieJar performs an HTTP request with cookie jar support and returns an HttpxResponse