WriteHeader method can only be called once per HTTP response, for obvious reasons: You can only have a single response code, and you can only send the headers once.
The error you see means that it is called a second time on the same response.
Your middleware calls:
Then your handler also calls:
http.Redirect(w, r, "/dashboard", 307) log.Println("-----") return views.Dashboard.Index.Render(w, login, helpers.AcceptsGzip(r))
Your middleware should never call
WriteHeader, until after the fate of the response is known.
Further, without knowing about your particular MVC framework, it seems possible that after you send the
307 status, then you also tell the MVC framework to render a response, which may also call