http

package
v1.33.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package http provides a net/http and a fetch implementation of http requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Opts

	// Logger is the default logger, none if nil.
	Logger *logrus.Entry
}

Client is the http client type (struct).

Values set on the Request override values set on Client.

var DefaultClient *Client = &Client{}

DefaultClient is the default client.

func (*Client) Do

func (c *Client) Do(r *Request) (*Response, error)

Do performs the request with the client.

type Opts

type Opts = fetch.CommonOpts

Opts are common fetch options.

type Request

type Request struct {
	fetch.Opts

	// URL specifies the URL to access.
	URL *url.URL
}

Request is the http request type (struct).

func NewRequest

func NewRequest(method, urlStr string, body io.Reader) (*Request, error)

NewRequest constructs a new http request.

func NewRequestWithContext

func NewRequestWithContext(ctx context.Context, method, url string, body io.Reader) (*Request, error)

NewRequestWithContext constructs a new http request with a context.

func (*Request) Clone

func (r *Request) Clone(ctx context.Context) *Request

Clone returns a deep copy of r with its context changed to ctx. The provided ctx must be non-nil.

Clone only makes a shallow copy of the Body field.

func (*Request) Context

func (r *Request) Context() context.Context

Context returns the request's context. To change the context, use Request.Clone or Request.WithContext.

The returned context is always non-nil; it defaults to the background context.

The context controls cancelation.

func (*Request) WithContext

func (r *Request) WithContext(ctx context.Context) *Request

WithContext returns a shallow copy of r with its context changed to ctx. The provided ctx must be non-nil.

type Response

type Response = fetch.Response

Response is the http response type.

func DoRequest

func DoRequest(le *logrus.Entry, client *Client, req *Request, verbose bool) (*Response, error)

DoRequest performs a request with logging.

If verbose=true, logs successful cases as well as errors. le can be nil to disable logging client can be nil

Jump to

Keyboard shortcuts

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