Documentation
¶
Overview ¶
Package httpmw contains http middlewares.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPPayload ¶
type HTTPPayload struct { // The request method. Examples: "GET", "HEAD", "PUT", "POST". RequestMethod string `json:"requestMethod"` // The scheme (http, https), the host name, the path and the query portion of // the URL that was requested. // // Example: "http://example.com/some/info?color=red". RequestURL string `json:"requestUrl"` // The response code indicating the status of response. // // Examples: 200, 404. Status int `json:"status"` // The user agent sent by the client. // // Example: "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Q312461; .NET CLR 1.0.3705)". UserAgent string `json:"userAgent"` // The IP address (IPv4 or IPv6) of the client that issued the HTTP request. // // Examples: "192.168.1.1", "FE80::0202:B3FF:FE1E:8329". RemoteIP string `json:"remoteIp"` // The IP address (IPv4 or IPv6) for whom the request is forwarded for. // // Examples: "192.168.1.1", "FE80::0202:B3FF:FE1E:8329". ForwardedFor string `json:"forwarded_for"` // The request processing duration on the server, from the time the request was // received until the response was sent. Duration string `json:"duration"` // The referrer URL of the request, as defined in HTTP/1.1 Header Field // Definitions. Referrer string `json:"referrer"` }
HTTPPayload is the complete payload that can be logged.
func (*HTTPPayload) MarshalLogObject ¶
func (req *HTTPPayload) MarshalLogObject(enc zapcore.ObjectEncoder) error
MarshalLogObject implements zapcore.ObjectMarshaler interface.
type RequestLogger ¶
type RequestLogger struct {
// contains filtered or unexported fields
}
RequestLogger provides method to log http requests.
func NewRequestLogger ¶
func NewRequestLogger(l *zap.Logger) *RequestLogger
NewRequestLogger returns http handler to log requests.
func (*RequestLogger) WithLogger ¶
func (l *RequestLogger) WithLogger(next http.Handler) http.Handler
WithLogger returns a logging middleware to log http request.
Click to show internal directories.
Click to hide internal directories.