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.
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) WriteHeader ¶
func (log *RequestLog) WriteHeader(code int)