httpc

package
v0.0.34 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2025 License: Apache-2.0 Imports: 6 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 service in context")
)

Functions

func MustClient

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

MustClient retrieves the http client from the context or returns the default http client

Types

type Option added in v0.0.26

type Option func(*Service)

func WithTimeout added in v0.0.26

func WithTimeout(d time.Duration) Option

WithTimeout sets the timeout directly.

func WithTimeoutString added in v0.0.26

func WithTimeoutString(v string) Option

WithTimeoutString parses a string like "5s" or "2m" and sets the timeout.

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() *nethttp.Client

Client returns the underlying http client

func (*Service) ToContext

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

Jump to

Keyboard shortcuts

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