hnygoji

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

README

Documentation available via godoc

Documentation

Overview

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(handler http.Handler) http.Handler

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

Example
// 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)
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

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