Created
May 8, 2014 02:00
-
-
Save lachsh/3c26dab21fc1084ea8ec to your computer and use it in GitHub Desktop.
Golang Gorilla Middleware
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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