request

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do[T error](client *client.HTTP, req *http.Request) (*http.Response, error)

Do sends the HTTP request req using the client and returns the response.

func NewHTTP

func NewHTTP(ctx context.Context, method, url string, body io.Reader, opts ...Option) (*http.Request, error)

NewHTTP creates a new HTTP request from the provided parameters and returns it. If the passed in context is nil, it creates a new background context. If the provided body is nil, it gets initialized to bytes.Reader. By default the following headers are set: * Accept: application/json; charset=utf-8 If no Content-Type has been set via options it defaults to application/json.

Types

type Option

type Option func(*http.Request)

Option is http request functional option.

func WithAddHeader

func WithAddHeader(key, val string) Option

WithAddHeader adds the val to key header.

func WithBearer

func WithBearer(token string) Option

WithBearer sets the Authorization header to the provided Bearer token.

func WithSetHeader

func WithSetHeader(key, val string) Option

WithSetHeader sets the header key to value val.

Jump to

Keyboard shortcuts

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