httpclient

package
v0.0.0-...-5bc8923 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthorizationHeader   = "Authorization"
	ContentTypeHeader     = "Content-Type"
	WWWAuthenticateHeader = "WWW-Authenticate"

	JSONMimeType = "application/json"
)

Constants for setting HTTP request headers.

Variables

This section is empty.

Functions

This section is empty.

Types

type Challenger

type Challenger interface {
	ChallengeAccepted(*http.Response) bool
	ChallengeResponse(r *http.Request, resp *http.Response) (*http.Request, error)
}

Challenger defines methods to handle HTTP authentication challenges. Implementations determine if a response requires authentication and generate the appropriate challenge response for subsequent requests.

type DispatchOption

type DispatchOption func(*Dispatcher)

DispatchOption is a function that modifies dispatch behavior.

func WithBinding

func WithBinding(bind any) DispatchOption

WithBinding returns a DispatchOption that configures a response bind to the provided target. The target must be a pointer to a type that can receive the response data.

func WithChallenger

func WithChallenger(challenger Challenger) DispatchOption

WithChallenger returns a DispatchOption that adds challenge handling to the dispatch operation.

func WithUnmarshaler

func WithUnmarshaler(u *json.Unmarshalers) DispatchOption

WithUnmarshaler returns a DispatchOption that configures a JSON unmarshaler for the provided bind target.

type Dispatcher

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

Dispatcher handles HTTP request dispatching with support for functional options.

func NewDispatcher

func NewDispatcher(client *http.Client) *Dispatcher

NewDispatcher creates a new *Dispatcher instance with the provided HTTP client.

func (*Dispatcher) Dispatch

func (d *Dispatcher) Dispatch(r *http.Request, opts ...DispatchOption) error

Dispatch an HTTP request and (optionally) unmarshal the payload.