Skip to content

Instantly share code, notes, and snippets.

@hashbender
Last active April 20, 2017 18:55
Show Gist options
  • Save hashbender/d9baf642c31e57d78cf80169487eb80f to your computer and use it in GitHub Desktop.
Save hashbender/d9baf642c31e57d78cf80169487eb80f to your computer and use it in GitHub Desktop.
//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