hnynethttp

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

README

Documentation available via godoc

Documentation

Overview

Package hnynethttp provides Honeycomb wrappers for net/http Handlers.

Summary

hnynethttp provides wrappers for the `net/http` types: Handler and HandlerFunc

For best results, use WrapHandler to wrap the mux passed to http.ListenAndServe - this will get you an event for every HTTP request handled by the server.

Wrapping individual Handlers or HandleFuncs will generate events only for the endpoints that are wrapped; 404s, for example, will not generate events.

For a complete example showing this wrapper in use, please see the examples in https://github.com/honeycombio/beeline-go/tree/master/examples

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapHandler

func WrapHandler(handler http.Handler) http.Handler

WrapHandler will create a Honeycomb event per invocation of this handler with all the standard HTTP fields attached. If passed a ServeMux instead, pull what you can from there

Example
// assume you have a handler named hello
var hello func(w http.ResponseWriter, r *http.Request)

globalmux := http.NewServeMux()
// add a bunch of routes to the muxer
globalmux.HandleFunc("/hello/", hello)

// wrap the globalmux with the honeycomb middleware to send one event per
// request
http.ListenAndServe(":8080", WrapHandler(globalmux))
Output:

func WrapHandlerFunc

func WrapHandlerFunc(hf func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request)

WrapHandlerFunc will create a Honeycomb event per invocation of this handler function with all the standard HTTP fields attached.

Example
// assume you have a handler function named helloServer
var helloServer func(w http.ResponseWriter, r *http.Request)

http.HandleFunc("/hello", WrapHandlerFunc(helloServer))
Output:

func WrapRoundTripper added in v0.2.0

func WrapRoundTripper(r http.RoundTripper) http.RoundTripper

WrapRoundTripper wraps an http transport for outgoing HTTP calls. Using a wrapped transport will send an event to Honeycomb for each outbound HTTP call you make. Include a context with outbound requests when possible to enable correlation

Types

This section is empty.

Jump to

Keyboard shortcuts

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