mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-03-22 18:09:21 +00:00
httputil: Fixed JSON body not reusable
This commit is contained in:
parent
d940a97a0f
commit
de3049b730
|
@ -81,11 +81,10 @@ func WithJSONBody(v interface{}) RequestOption {
|
|||
return func(httpdriver.Request) error { return nil }
|
||||
}
|
||||
|
||||
var rp, wp = io.Pipe()
|
||||
|
||||
go func() { wp.CloseWithError(json.EncodeStream(wp, v)) }()
|
||||
|
||||
return func(r httpdriver.Request) error {
|
||||
rp, wp := io.Pipe()
|
||||
go func() { wp.CloseWithError(json.EncodeStream(wp, v)) }()
|
||||
|
||||
r.AddHeader(http.Header{
|
||||
"Content-Type": {"application/json"},
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue