EnvInit is a middleware that allocates an environment map if it is nil. While it's impossible in general to ensure that Env is never nil in a middleware stack, in most common cases placing this middleware at the top of the stack will eliminate the need for repetative nil checks.
// Goji, so there's a chance someone has already written the middleware // you are looking for! m.Use(middleware.EnvInit) m.Use(logger) m.Use(auth)
EnvInit is referenced in 12 repositoriesgithub.com/zenazn/goji
- 1 reference in web/example_test.go
- 1 reference in server.go