1

I'm building a web service in Go. I use Negroni, unrolled/Render and Gorilla Mux.

I'm trying to write some simple middleware myself for caching http responses and being completly new to Golang a few questions came up...

Is there a way in which I can read what a handler's render.JSON(...) was when my midlleware is executed from the return of the handler.

Demo code below...

func MyMiddleWareHandler(w http.ResponseWriter, r *http.Request,next http.HandlerFunc) {
    // First call the next/final handler
    next(w, r)
    //Now read the Render.JSON(...) executed by the handler called by next method above...  
}
Cyberlurk
  • 766
  • 3
  • 9
  • 30
  • 2
    See here for some examples on hijacking the ResponseWriter - https://justinas.org/writing-http-middleware-in-go/ – elithrar Apr 05 '15 at 01:10
  • you should look gin framework. http://gin-gonic.github.io/gin ,it has lot of good api to read and render json. – Akash Shinde Apr 05 '15 at 09:38

0 Answers0