mirror of
https://github.com/safing/portbase
synced 2025-09-04 03:29:59 +00:00
Restore http.Request body for http.HandlerFunc in api package
This commit is contained in:
parent
85f8832911
commit
ba6dee246b
1 changed files with 5 additions and 0 deletions
|
@ -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)
|
||||||
|
|
Loading…
Add table
Reference in a new issue