Restore http.Request body for http.HandlerFunc in api package

This commit is contained in:
Patrick Pacher 2022-05-03 16:09:40 +02:00
parent 85f8832911
commit ba6dee246b
No known key found for this signature in database
GPG key ID: E8CD2DA160925A6D

View file

@ -1,9 +1,11 @@
package api package api
import ( import (
"bytes"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"sort" "sort"
@ -413,6 +415,9 @@ func (e *Endpoint) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return return
} }
apiRequest.InputData = inputData apiRequest.InputData = inputData
// restore request body for any http.HandlerFunc below
r.Body = io.NopCloser(bytes.NewReader(inputData))
default: default:
// Defensive. // Defensive.
http.Error(w, "unsupported method for the actions API", http.StatusMethodNotAllowed) http.Error(w, "unsupported method for the actions API", http.StatusMethodNotAllowed)