Help us shape the future of Go! Take the 2026 Go Developer Survey

httplog

package
v1.34.9 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoRequest

func DoRequest(le *logrus.Entry, client *http.Client, req *http.Request, verbose bool) (*http.Response, error)

DoRequest performs a request with logging.

If verbose=true, logs successful cases as well as errors. le can be nil to disable logging

func DoRequestWithClient

func DoRequestWithClient(le *logrus.Entry, client HttpClient, req *http.Request, verbose bool) (*http.Response, error)

DoRequestWithClient performs a request with logging.

If verbose=true, logs successful cases as well as errors. le can be nil to disable logging

func DoRequestWithTransport

func DoRequestWithTransport(le *logrus.Entry, transport http.RoundTripper, req *http.Request, verbose bool) (*http.Response, error)

DoRequestWithTransport performs a request with logging.

If verbose=true, logs successful cases as well as errors. le can be nil to disable logging

func LoggingMiddleware

func LoggingMiddleware(next http.Handler, le *logrus.Entry, opts LoggingMiddlewareOpts) http.Handler

LoggingMiddleware logs incoming requests and response status codes using logrus.

func WithLoggerFields

func WithLoggerFields(le *logrus.Entry, r *http.Request, status int) *logrus.Entry

WithLoggerFields builds the log fields for a request.

Types

type HttpClient

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HttpClient can perform http requests.

func NewLoggedClient

func NewLoggedClient(le *logrus.Entry, client HttpClient, verbose bool) HttpClient

NewLoggedClient wraps an HttpClient with a logger.

type LoggedRoundTripper

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

LoggedRoundTripper is a custom RoundTripper that wraps an existing RoundTripper with a logger.

func NewLoggedRoundTripper

func NewLoggedRoundTripper(transport http.RoundTripper, le *logrus.Entry, verbose bool) *LoggedRoundTripper

NewLoggedRoundTripper creates a new instance of LoggedRoundTripper.

func (*LoggedRoundTripper) RoundTrip

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

RoundTrip implements the RoundTripper interface.

type LoggingMiddlewareOpts

type LoggingMiddlewareOpts struct {
	// UserAgent includes user agent in logs.
	UserAgent bool
}

LoggingMiddlewareOpts are opts passed to LoggingMiddleware.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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