beeline-go: github.com/honeycombio/beeline-go/wrappers/hnygoji Index | Examples | Files

package hnygoji

import "github.com/honeycombio/beeline-go/wrappers/hnygoji"

Package hnygoji has Middleware to use with the Goji muxer.

Summary

hnygoji has Middleware to wrap individual handlers, and is best used in conjunction with the nethttp WrapHandler function. Using these two together will get you an event for every request that comes through your application while also decorating the most interesting paths (the hantdlers that you wrap) with additional fields from the Goji patterns.

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

Package Files

doc.go goji.go

func Middleware Uses

func Middleware(handler http.Handler) http.Handler

Middleware is specifically to use with goji's router.Use() function for inserting middleware

Code:

// assume you have handlers for hello and bye
var hello func(w http.ResponseWriter, r *http.Request)
var bye func(w http.ResponseWriter, r *http.Request)

// this example uses a submux just to illustrate the middleware's use
root := goji.NewMux()
greetings := goji.SubMux()
root.Handle(pat.New("/greet/*"), greetings)
greetings.HandleFunc(pat.Get("/hello/:name"), hello)
greetings.HandleFunc(pat.Get("/bye/:name"), bye)

// decorate calls that hit the greetings submux with extra fields
greetings.Use(Middleware)

Package hnygoji imports 7 packages (graph) and is imported by 1 packages. Updated 2019-03-22. Refresh now. Tools for package owners.