You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I discovered this while trying to implement a cache handler. We don't want to cache all of our requests, so we'd like to pass the cache handler to the router. In order to do this, however, Renderer has to be passed to every route as well and after the cache.
Example:
martiniServer.Use(render.Renderer())
router:=martini.NewRouter()
// Caching won't work here because it wants to intercept and// and replace the http.ResponseWriter, but Render has a// reference to the original ResponseWriter. The replaced one// will never be used.router.Get("/", cache, func(r render.Render) {
r.HTML(200, "index", "Welcome")
}
Is it necessary to capture the ResponseWriter? Is there a better way to do what I'm trying to do?
The text was updated successfully, but these errors were encountered:
This is because render uses the ResponseWriter that is injected into it's handler function.
render.Renderer could grab the ResponseWriter from the context right before it renders things, but that would require some changes and introduce some undesired behavior. I'm willing to explore the idea given that it doesn't break existing functionality
I discovered this while trying to implement a cache handler. We don't want to cache all of our requests, so we'd like to pass the cache handler to the router. In order to do this, however, Renderer has to be passed to every route as well and after the cache.
Example:
Is it necessary to capture the ResponseWriter? Is there a better way to do what I'm trying to do?
The text was updated successfully, but these errors were encountered: