Documentation
¶
Index ¶
- Variables
- func AsData(body io.ReadCloser, dst *[]byte) (err error)
- func AsJson(body io.ReadCloser, dst any) (err error)
- func AsNothing(body io.ReadCloser) (err error)
- func Do(req *http.Request) (*http.Response, error)
- func DoJson(ctx context.Context, method string, url string, body any) (*http.Response, error)
- func DoReader(ctx context.Context, method string, url string, body io.Reader) (*http.Response, error)
- func HandleEvent(handler http.Handler) http.Handler
- func HandleLogger(handler http.Handler) http.Handler
- func MakeErrorUnexpectedStatusCode(statusCode int) error
- func NewStatisticResponseWriter(wrapped http.ResponseWriter) *statisticResponseWriter
- func WithHttpClient(ctx context.Context, client HttpClient) context.Context
- func WriteData(w http.ResponseWriter, status int, src []byte) (err error)
- func WriteJson(w http.ResponseWriter, status int, src any) (err error)
- type HttpClient
- type HttpClientFunc
- type Wrapper
- type WrapperFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrUnexpectedStatusCode = errors.New("unexpected status code")
)
Functions ¶
func AsNothing ¶
func AsNothing(body io.ReadCloser) (err error)
func NewStatisticResponseWriter ¶
func NewStatisticResponseWriter(wrapped http.ResponseWriter) *statisticResponseWriter
func WithHttpClient ¶
func WithHttpClient(ctx context.Context, client HttpClient) context.Context
Types ¶
type HttpClient ¶
var Default HttpClient = WrapHttpClient(http.DefaultClient, WithLogger(), WithEvent())
func GetHttpClient ¶
func GetHttpClient(ctx context.Context) HttpClient
func WrapHttpClient ¶
func WrapHttpClient(client HttpClient, wrappers ...Wrapper) HttpClient
type HttpClientFunc ¶
type Wrapper ¶
type Wrapper interface {
Wrap(client HttpClient) HttpClient
}
func WithLogger ¶
func WithLogger() Wrapper
func WithUserAgent ¶
type WrapperFunc ¶
type WrapperFunc func(client HttpClient) HttpClient
func (WrapperFunc) Wrap ¶
func (wrapper WrapperFunc) Wrap(client HttpClient) HttpClient
Click to show internal directories.
Click to hide internal directories.