httplog

package module
v0.0.0-...-580d0d4 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2016 License: BSD-3-Clause Imports: 13 Imported by: 51

README

httplog

GoDoc

Package httplog provides log facilitites for http servers written in Go.

Documentation

Overview

Package httplog provides logging for http requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApacheCombinedFormat

func ApacheCombinedFormat(l *log.Logger) httpmux.MiddlewareFunc

ApacheCombinedFormat returns a middleware that logs http requests to the given logger using the Apache Combined log format.

func ApacheCommonFormat

func ApacheCommonFormat(l *log.Logger) httpmux.MiddlewareFunc

ApacheCommonFormat returns a middleware that logs http requests to the given logger using the Apache Common log format.

func DefaultFormat

func DefaultFormat(l *log.Logger) httpmux.MiddlewareFunc

DefaultFormat returns a middleware that logs http requests to the given logger using the default log format.

func Error

func Error(r *http.Request, v ...interface{})

Error associates message v with the request context.

func Errorf

func Errorf(r *http.Request, format string, v ...interface{})

Errorf associates message v with the request context.

func Errorln

func Errorln(r *http.Request, v ...interface{})

Errorln associates message v with the request context.

func UseXForwardedFor

func UseXForwardedFor(next http.HandlerFunc) http.HandlerFunc

UseXForwardedFor parses the first value from the X-Forwarded-For header and updates the request RemoteAddr field with it, then call the next handler and reverts the value back at the end.

Types

type ErrorType

type ErrorType int

ErrorType is the type used for storing error in a context.Context.

var ErrorID ErrorType

ErrorID is the key used for storing and retrieving errors to/from context.

type ResponseRecorder

type ResponseRecorder interface {
	Code() int  // Response status code
	Bytes() int // Bytes written to the client
}

The ResponseRecorder interface is implemented by ResponseWriters that can record the response status code and bytes written to the client.

type ResponseWriter

type ResponseWriter struct {
	http.ResponseWriter
	http.Hijacker
	http.Flusher
	http.CloseNotifier
	ResponseRecorder
	// contains filtered or unexported fields
}

ResponseWriter is an http.ResponseWriter + ResponseRecorder.

func NewResponseWriter

func NewResponseWriter(w http.ResponseWriter) *ResponseWriter

NewResponseWriter creates and initializes a new ResponseWriter.

func (*ResponseWriter) Bytes

func (w *ResponseWriter) Bytes() int

Bytes implements the ResponseRecorder interface.

func (*ResponseWriter) CloseNotify

func (w *ResponseWriter) CloseNotify() <-chan bool

CloseNotify implements the http.CloseNotififer interface.

func (*ResponseWriter) Code

func (w *ResponseWriter) Code() int

Code implements the ResponseRecorder interface.

func (*ResponseWriter) Flush

func (w *ResponseWriter) Flush()

Flush implements the http.Flusher interface.

func (*ResponseWriter) Header

func (w *ResponseWriter) Header() http.Header

Header implements the http.ResponseWriter interface.

func (*ResponseWriter) Hijack

func (w *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)

Hijack implements the http.Hijacker interface.

func (*ResponseWriter) Write

func (w *ResponseWriter) Write(b []byte) (int, error)

Write implements the http.ResponseWriter interface.

func (*ResponseWriter) WriteHeader

func (w *ResponseWriter) WriteHeader(code int)

WriteHeader implements the http.ResponseWriter interface.

Jump to

Keyboard shortcuts

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