whmon

package
v1.0.0-...-3f30213 Latest Latest
Warning

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

Go to latest
Published: May 30, 2017 License: Apache-2.0 Imports: 8 Imported by: 11

Documentation

Overview

Package whmon provides a means to monitor various aspects of how the request and response is going.

Index

Constants

This section is empty.

Variables

View Source
var (
	RequestId = webhelp.GenSym()
)

Functions

func MonitorResponse

func MonitorResponse(h http.Handler) http.Handler

MonitorResponse wraps all incoming http.ResponseWriters with a monitored ResponseWriter that keeps track of additional status information about the outgoing response. It preserves whether or not the passed in response writer is an http.Flusher, http.CloseNotifier, or an http.Hijacker. whlog.LogRequests and whfatal.Catch also do this for you.

func RequestIds

func RequestIds(h http.Handler) http.Handler

RequestIds generates a new request id for the request if one does not already exist under the Request Context Key RequestId. The RequestId can be retrieved using:

rid := whcompat.Context(req).Value(whmon.RequestId).(int64)

Types

type ResponseWriter

type ResponseWriter interface {
	// Header, Write, and WriteHeader are exactly like http.ResponseWriter
	Header() http.Header
	Write([]byte) (int, error)
	WriteHeader(int)

	// WroteHeader returns true if the Header was sent out. Note that this can
	// happen if only Write is called.
	WroteHeader() bool
	// StatusCode returns the HTTP status code the Header sent.
	StatusCode() int
	// Written returns the total amount of bytes successfully passed through the
	// Write call. This does not include the header.
	Written() int64
}

Jump to

Keyboard shortcuts

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