httputil

package
v0.0.0-...-7b7c10a Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapWithDumpTransport

func WrapWithDumpTransport(client *http.Client) *http.Client

WrapWithDumpTransport wraps existing http.Client's transport with transport that dumps requests and responses.

Types

type DumpTransport

type DumpTransport struct {
	// contains filtered or unexported fields
}

DumpTransport is http.RoundTripper that dumps requests and responses.

func (*DumpTransport) RoundTrip

func (d *DumpTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the RoundTripper interface.

type Opt

type Opt func(*options)

Opt configures HTTP request options.

func WithAuthToken

func WithAuthToken(token string) Opt

WithAuthToken specifies an authorization token.

func WithBody

func WithBody(val []byte) Opt

WithBody specifies HTTP request body.

func WithHTTPClient

func WithHTTPClient(c *http.Client) Opt

WithHTTPClient specifies the custom HTTP client.

func WithMethod

func WithMethod(val string) Opt

WithMethod specifies an HTTP method. Default is GET.

func WithParsedResponse

func WithParsedResponse(r interface{}) Opt

WithParsedResponse specifies type to unmarshal response body.

func WithSigner

func WithSigner(signer requestSigner) Opt

WithSigner specifies a request signer for HTTP Signatures.

type Response

type Response struct {
	Status       string
	StatusCode   int
	Body         []byte
	ErrorMessage string
}

Response is an HTTP response.

func DoRequest

func DoRequest(ctx context.Context, url string, opts ...Opt) (*Response, error)

DoRequest makes an HTTP request.

Jump to

Keyboard shortcuts

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