logrequest

package
v0.0.0-...-14ea052 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2016 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package logrequest implements a middleware that logs requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogRequest

type LogRequest struct {
	// Logger is the logger to use to log the requests.
	Logger httpcmw.Logger

	// RequestIDHeader is the name of the header that contains the request
	// ID. Defaults to X-Request-Id.
	RequestIDHeader string

	// TimeFormat is the format to use to format timestamps, as supported by
	// the time package.
	TimeFormat string

	// DurationFormat is the format to use to log the duration of the request.
	// The value to format is the number of seconds in float64. Defaults to
	// %.3f (milliseconds).
	DurationFormat string

	// Fields is the list of field names to log. Defaults to all supported
	// fields. The supported fields are:
	//
	//     body_bytes_received: bytes received in the response body
	//     duration: duration of the request
	//     end: date and time of the end of the request (UTC)
	//     error: error returned from the request, if any
	//     host: host (and possibly port) of the request
	//     method: method of the request (e.g. GET)
	//     path: path section of the request URL
	//     proto: protocol and version (e.g. HTTP/1.1)
	//     query: query string section of the request URL
	//     request_id: request id
	//     start: date and time of the start of the request (UTC)
	//     status: status code of the response, if any
	//     user_agent: value of the User-Agent request header
	//
	Fields []string
}

LogRequest holds the configuration for the LogRequest middleware.

func (*LogRequest) Wrap

func (lr *LogRequest) Wrap(d httpcmw.Doer) httpcmw.Doer

Wrap returns a Doer that records the start time, calls the Doer d, records the end time and duration, and logs the request's fields as configured by the LogRequest.

Jump to

Keyboard shortcuts

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