20 lines
340 B
Go
20 lines
340 B
Go
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
|
|
}
|