fbhttplogger

package
v0.0.0-...-e848abc Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2015 License: MIT, MIT Imports: 4 Imported by: 0

Documentation

Overview

The fbhttplogger package contains a http.Handler wrapper that sends logs requests to a Forest Bus topic.

This is intended as an example of how Forest Bus can be integrated into a standard Go http handler application. The NewHandler function takes a http.Handler and a forestbus.MessageBatcher and generates json messages to the MessageBatcher for each HTTP request sent to the handler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

An http.Handler that provides Forest Bus logging. Create using the NewHandler function.

func NewHandler

func NewHandler(wrappedHandler http.Handler, batcher *forestbus.MessageBatcher, blockIfFull bool) *Handler

Creates a http.Handler object that logs all requests to Forest Bus by creating and sending a RequestLog object in JSON format.

blockIfFull blocks the goroutine handling the request if the Message Batcher is full.

func (*Handler) ServeHTTP

func (handler *Handler) ServeHTTP(writer http.ResponseWriter, request *http.Request)

type RequestLog

type RequestLog struct {
	RequestHeaders   http.Header
	Method           string
	Url              string
	Host             string
	RemoteAddr       string
	Referer          string
	UserAgent        string
	ResponseHeaders  http.Header
	ResponseCode     int
	ResponseBodySize int
	// contains filtered or unexported fields
}

RequestLog defines the JSON format used to log requests and HTTP response information to a Forest Bus topic.

func (*RequestLog) Header

func (log *RequestLog) Header() http.Header

func (*RequestLog) Write

func (log *RequestLog) Write(data []byte) (int, error)

func (*RequestLog) WriteHeader

func (log *RequestLog) WriteHeader(code int)

Jump to

Keyboard shortcuts

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