httpc

package
v0.1.65 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoHttpServiceInContext  = errors.New("no http service in context")
	ErrInvalidServiceInContext = errors.New("invalid http service in context")
)

Functions

func HttpStatusErr

func HttpStatusErr(hr *http.Response, body []byte) error

func MapHTTPToDomain

func MapHTTPToDomain(status int) error

func MustClient

func MustClient(ctx context.Context) *http.Client

Types

type AuthTransport

type AuthTransport struct {
	Editor authenticator.RequestEditor
	// contains filtered or unexported fields
}

func (*AuthTransport) RoundTrip

func (t *AuthTransport) RoundTrip(req *http.Request) (*http.Response, error)

type LogTransport

type LogTransport struct {
	WithBody bool
	Log      *slog.Logger
	// contains filtered or unexported fields
}

func (*LogTransport) RoundTrip

func (t *LogTransport) RoundTrip(req *http.Request) (*http.Response, error)

type Option

type Option func(*Service)

func WithAuthEditor

func WithAuthEditor(ed authenticator.RequestEditor) Option

WithAuthEditor Install an auth editor transport now

func WithCookieJar

func WithCookieJar() Option

WithCookieJar Ensure cookie jar (needed for XSRF)

func WithTimeout

func WithTimeout(d time.Duration) Option

func WithTimeoutString

func WithTimeoutString(v string) Option

type Service

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

func FromContext

func FromContext(ctx context.Context) (*Service, error)

func New

func New(cfg *config.Config, log *slog.Logger, opts ...Option) (*Service, error)

func (*Service) Client

func (s *Service) Client() *http.Client

func (*Service) InstallAuthEditor

func (s *Service) InstallAuthEditor(ed authenticator.RequestEditor)

func (*Service) InstallCookieJar

func (s *Service) InstallCookieJar() error

func (*Service) ToContext

func (s *Service) ToContext(ctx context.Context) context.Context

func (*Service) UseClient

func (s *Service) UseClient(c *http.Client)

Jump to

Keyboard shortcuts

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