http

package
v0.0.0-...-06831c0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fallbacks

func Fallbacks(ff ...string) configurator

func FileServer

func FileServer(files fs.FS, cc ...configurator) (h *fileServer, err error)

func Logger

func Logger(l *zap.Logger) configurator

func MountSPA

func MountSPA(r chi.Router, path string, root fs.FS, cc ...configurator) error

MountSPA helper function, preconfigures FileServer for SPA serving and mounts it to chi Router

func NotFound

func NotFound(h http.HandlerFunc) configurator

func SetupDefaults

func SetupDefaults(timeout time.Duration, tlsInsecure bool)

SetupDefaults Reconfigures defaults for HTTP client & transport

func ToError

func ToError(resp *http.Response) error

func UrlPrefix

func UrlPrefix(prefix string) configurator

Types

type BufferedReader

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

The BufferedReader behaves exactly like a bytes.Reader, with the exception when the last block is read, it automatically rewinds the internal pointer to the start, so effectively, the content can be read again without calling Seek() externally.

func NewBufferedReader

func NewBufferedReader(rr io.Reader) (bb *BufferedReader, err error)

NewBufferedReader copies original data to the BufferedReader

func (*BufferedReader) Read

func (r *BufferedReader) Read(b []byte) (n int, err error)

func (*BufferedReader) Seek

func (r *BufferedReader) Seek(offset int64, whence int) (int64, error)

type Client

type Client struct {
	Transport *http.Transport
	Client    *http.Client
	// contains filtered or unexported fields
}

func New

func New(flags *Config) (*Client, error)

func (*Client) Debug

func (c *Client) Debug(level DebugLevel) *Client

func (*Client) Delete

func (c *Client) Delete(url string) (*http.Request, error)

func (*Client) Do

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

func (*Client) Get

func (c *Client) Get(url string) (*http.Request, error)

func (*Client) Patch

func (c *Client) Patch(url string, body interface{}) (*http.Request, error)

func (*Client) Post

func (c *Client) Post(url string, body interface{}) (*http.Request, error)

func (*Client) Request

func (c *Client) Request(method, url string, body interface{}) (*http.Request, error)

type Config

type Config struct {
	BaseURL string
	Timeout int
}

type DebugLevel

type DebugLevel string
const (
	INFO DebugLevel = "info"
	FULL DebugLevel = "full"
)

type Request

type Request struct {
	*http.Request
	Body io.Reader
}

func NewRequest

func NewRequest(r *http.Request) (rr *Request, err error)

func (*Request) MarshalJSON

func (bb *Request) MarshalJSON() ([]byte, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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