Skip to content

Instantly share code, notes, and snippets.

@lachholden
Created May 8, 2014 02:00
Show Gist options
  • Save lachholden/3c26dab21fc1084ea8ec to your computer and use it in GitHub Desktop.
Save lachholden/3c26dab21fc1084ea8ec to your computer and use it in GitHub Desktop.
Golang Gorilla Middleware
// context key values
const (
DB = iota
)
func DbMiddleware(handler http.Handler, db *gorp.DbMap) {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
context.Set(r, DB, db)
handler.ServeHTTP(w, r)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment