httpClient

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCallerFunctionName

func GetCallerFunctionName() string

GetCallerFunctionName for extracting name of next to next caller function

Types

type HTTPClient

type HTTPClient struct {
	Client       *http.Client
	TraceEnabled bool
	ServiceName  string
}

HTTPClient wrapper over net/http client with tracing

func NewHTTPClient

func NewHTTPClient(opt ...HTTPClientOption) *HTTPClient

NewHTTPClient creates a new HTTPClient with DefaultTransport TODO: add options to configure transport

func (*HTTPClient) Do

func (c *HTTPClient) Do(request *http.Request) (*http.Response, error)

Do makes an HTTP request with the native `http.Do` interface

type HTTPClientOption

type HTTPClientOption func(client *HTTPClient)

HTTPClientOption different options to configure the HTTPClient

func WithTraceEnabled

func WithTraceEnabled(e bool) HTTPClientOption

WithTraceEnabled allows to toggle tracing

type HTTPError

type HTTPError struct {
	StatusCode int
	Status     string
	Body       string
}

HTTPError Custom error type to be returned for status code < 200 and >300

func (*HTTPError) Error

func (e *HTTPError) Error() string

Jump to

Keyboard shortcuts

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