helpers

package
v0.75.3 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package helpers provides utility functions for working with HTTP requests and responses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeJSONBody

func DecodeJSONBody(resp *http.Response, value any) error

func Fetch

func Fetch(ctx context.Context, req *http.Request, dst io.Writer) error

func FetchToFile

func FetchToFile(ctx context.Context, req *http.Request, dst string) error

FetchToFile downloads the file from the given `url` into the specified `dst` file.

func ModifyJSONBody

func ModifyJSONBody(resp *http.Response, value any, fn func() error) error

func ResponseBuffer

func ResponseBuffer(resp *http.Response) (*bytes.Buffer, error)

func ResponseReader

func ResponseReader(resp *http.Response) (io.ReadCloser, error)

Types

type Client added in v0.73.15

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

Client is an HTTP client.

func NewClient added in v0.73.15

func NewClient(credsSource *cliconfig.CredentialsSource) *Client

func (*Client) Do added in v0.73.15

func (client *Client) Do(ctx context.Context, method, reqURL string, value any) error

Do sends an HTTP request and decodes an HTTP response to the given `value`.

type ReverseProxy added in v0.73.15

type ReverseProxy struct {
	ServerURL   *url.URL
	CredsSource *cliconfig.CredentialsSource

	Rewrite        func(*httputil.ProxyRequest)
	ModifyResponse func(resp *http.Response) error
	ErrorHandler   func(http.ResponseWriter, *http.Request, error)

	Logger log.Logger
}

func (*ReverseProxy) NewRequest added in v0.73.15

func (reverseProxy *ReverseProxy) NewRequest(ctx echo.Context, targetURL *url.URL) (er error)

func (ReverseProxy) WithModifyResponse added in v0.73.15

func (reverseProxy ReverseProxy) WithModifyResponse(fn func(resp *http.Response) error) *ReverseProxy

func (ReverseProxy) WithRewrite added in v0.73.15

func (reverseProxy ReverseProxy) WithRewrite(fn func(req *httputil.ProxyRequest)) *ReverseProxy

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳