I have two http handlers that use the same http.ResponseWriter and *http.Request and read the request body like this:
func Method1 (w http.ResponseWriter, r *http.Request){
var postData database.User
if err := json.NewDecoder(r.Body).Decode(&postData); err != nil {
//return error
}
}
func Method2 (w http.ResponseWriter, r *http.Request){
var postData database.User
//this read gives (of course) EOF error
if err := json.NewDecoder(r.Body).Decode(&postData); err != nil {
//return error
}
}
Because of I need to keep these 2 methods separated, and both of them need to read the request Body, which is the best way (if it's possible) to Seek the request body (which is a ReadCloser, not a Seeker?).