I'm thinking about the following scenario:
Suppose I want have handler X in which I have made some calculations but now want to forward to another handler Y before returning the request.
It would be something like
func X(w http.ResponseWriter, r *http.Request, params httprouter.Params){
//calculations
if condition{
var fp httprouter.Params
fp = append(fp, httprouter.Param{Key: "KEY", Value: "VALUE"})
w.WriteHeader(301)
Y(w, r, fp)
return
}
}
The problem I have is that while the page loads and it has a 301 header the redirect is not registered. It's like a 200 page with a 301.
I know there's http.Redirect, but it doesn't forward the parameters that could be helpful. Is there an easy solution to this?