commit
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package netx
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// 读取POST请求的原始参数
|
||||
func GetOriginParams(r *http.Request) ([]byte, error) {
|
||||
buf := &bytes.Buffer{}
|
||||
tea := io.TeeReader(r.Body, buf)
|
||||
body, err := io.ReadAll(tea)
|
||||
if err != nil && err != io.EOF {
|
||||
return []byte{}, err
|
||||
}
|
||||
r.Body = io.NopCloser(buf)
|
||||
return body, nil
|
||||
}
|
||||
Reference in New Issue
Block a user