http

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: MIT Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDisallowedIP = errors.New("disallowed IP")

Functions

func NewRestrictedClient

func NewRestrictedClient(cfg clientConfig, lggr logger.Logger) *http.Client

NewRestrictedClient returns a secure HTTP Client (queries to certain local addresses are blocked)

func NewUnrestrictedClient

func NewUnrestrictedClient() *http.Client

NewUnrestrictedClient returns a HTTP Client with no Transport restrictions

Types

type Client

type Client interface {
	Do(req *http.Request) (*http.Response, error)
}

type Request

type Request struct {
	Client  Client
	Request *http.Request
	Config  RequestConfig
	Logger  logger.Logger
}

Request holds the request and config struct for a http request

func (*Request) SendRequest

func (h *Request) SendRequest() (responseBody []byte, statusCode int, headers http.Header, err error)

SendRequest sends a Request, returns a body, status code, and error.

func (*Request) SendRequestReader

func (h *Request) SendRequestReader() (responseBody io.ReadCloser, statusCode int, headers http.Header, err error)

SendRequestReader allows for streaming the body directly and does not read it all into memory

CALLER IS RESPONSIBLE FOR CLOSING RETURNED RESPONSE BODY

type RequestConfig

type RequestConfig struct {
	// SizeLimit in bytes
	SizeLimit int64
}

RequestConfig holds the configurable settings for a http request

Jump to

Keyboard shortcuts

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