Last active
April 20, 2017 18:55
-
-
Save hashbender/d9baf642c31e57d78cf80169487eb80f to your computer and use it in GitHub Desktop.
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
//ContextedHandler is a wrapper to provide AppContext to our Handlers | |
type ContextedHandler struct { | |
*AppContext | |
//ContextedHandlerFunc is the interface which our Handlers will implement | |
ContextedHandlerFunc func(*AppContext, http.ResponseWriter, *http.Request) (int, error) | |
} | |
//AppContext provides the app context to handlers. This *cannot* contain request-specific keys like | |
//sessionId or similar. It is shared across requests. | |
type AppContext struct { | |
Db *sql.DB | |
Redis *redis.Pool | |
//Whatever other context-y stuff you might need | |
//kafka, rabbit, zookeeper and other buzzwords | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment