request

package
v4.74.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 20 Imported by: 30

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoRedirection = func(*http.Request, []*http.Request) error {
	return http.ErrUseLastResponse
}

Functions

func AddOpenTelemetryToDefaultClient added in v4.63.1

func AddOpenTelemetryToDefaultClient(meterProvider metric.MeterProvider, tracerProvider trace.TracerProvider)

func AddSignature added in v4.20.0

func AddSignature(r *http.Request, created time.Time, keyID string, secret, payload []byte)

AddSignature add Authorization header based on content signature based on https://datatracker.ietf.org/doc/html/draft-cavage-http-signatures-12

func CreateClient added in v4.28.1

func CreateClient(timeout time.Duration, onRedirect func(*http.Request, []*http.Request) error) *http.Client

func CreateClientWithTransport added in v4.71.4

func CreateClientWithTransport(timeout time.Duration, onRedirect func(*http.Request, []*http.Request) error, transport http.RoundTripper) *http.Client

func DiscardBody added in v4.22.3

func DiscardBody(body io.ReadCloser) error

func Do

func Do(req *http.Request) (*http.Response, error)

func DoWithClient

func DoWithClient(client *http.Client, req *http.Request) (*http.Response, error)

func ReadBodyRequest

func ReadBodyRequest(r *http.Request) ([]byte, error)

func ReadBodyResponse

func ReadBodyResponse(r *http.Response) ([]byte, error)

func ValidateSignature added in v4.20.0

func ValidateSignature(r *http.Request, secret []byte) (bool, error)

ValidateSignature check Authorization header based on content based on https://datatracker.ietf.org/doc/html/draft-cavage-http-signatures-12

Types

type Request

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

func Delete added in v4.33.0

func Delete(url string) Request

func Get added in v4.33.0

func Get(url string) Request

func New

func New() Request

func Patch added in v4.33.0

func Patch(url string) Request

func Post added in v4.33.0

func Post(url string) Request

func Put added in v4.33.0

func Put(url string) Request

func (Request) Accept added in v4.39.2

func (r Request) Accept(accept string) Request

func (Request) AcceptJSON added in v4.39.2

func (r Request) AcceptJSON() Request

func (Request) BasicAuth

func (r Request) BasicAuth(username, password string) Request

func (Request) Build

func (r Request) Build(ctx context.Context, payload io.ReadCloser) (*http.Request, error)

func (Request) ContentForm

func (r Request) ContentForm() Request

func (Request) ContentJSON

func (r Request) ContentJSON() Request

func (Request) ContentLength added in v4.46.2

func (r Request) ContentLength(contentLength int64) Request

func (Request) ContentType

func (r Request) ContentType(contentType string) Request

func (Request) Delete

func (r Request) Delete(url string) Request

func (Request) Form

func (r Request) Form(ctx context.Context, data url.Values) (*http.Response, error)

func (Request) Get

func (r Request) Get(url string) Request

func (Request) Header

func (r Request) Header(name, value string) Request

func (Request) IsZero added in v4.22.2

func (r Request) IsZero() bool

func (Request) JSON

func (r Request) JSON(ctx context.Context, body any) (*http.Response, error)

func (Request) Method

func (r Request) Method(method string) Request

func (Request) MethodURL added in v4.37.2

func (r Request) MethodURL(method, url string) Request

func (Request) Multipart added in v4.40.0

func (r Request) Multipart(ctx context.Context, feed func(mw *multipart.Writer) error) (*http.Response, error)

func (Request) Patch

func (r Request) Patch(url string) Request

func (Request) Path added in v4.22.2

func (r Request) Path(path string, a ...any) Request

func (Request) Post

func (r Request) Post(url string) Request

func (Request) Put

func (r Request) Put(url string) Request

func (Request) Send

func (r Request) Send(ctx context.Context, payload io.ReadCloser) (*http.Response, error)

func (Request) StreamJSON added in v4.39.2

func (r Request) StreamJSON(ctx context.Context, body any) (*http.Response, error)

func (Request) String added in v4.23.0

func (r Request) String() string

func (Request) URL

func (r Request) URL(url string) Request

func (Request) WithClient

func (r Request) WithClient(client *http.Client) Request

func (Request) WithSignatureAuthorization added in v4.20.0

func (r Request) WithSignatureAuthorization(keyID string, secret []byte) Request

type RequestError added in v4.53.8

type RequestError struct {
	Header     http.Header
	Body       []byte
	StatusCode int
}

func NewResponseError added in v4.53.8

func NewResponseError(resp *http.Response) RequestError

func (RequestError) Error added in v4.53.8

func (re RequestError) Error() string

Jump to

Keyboard shortcuts

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