-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: put object tests and better logging (#38)
- Loading branch information
Showing
7 changed files
with
22,475 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package boltrouter | ||
|
||
import ( | ||
"bytes" | ||
"io" | ||
"net/http" | ||
) | ||
|
||
// copyReq copies the request body into a destination request. | ||
// this allows reading a request body multiple times without "closing" it | ||
func CopyReqBody(src *http.Request, dest *http.Request) { | ||
var b bytes.Buffer | ||
b.ReadFrom(src.Body) | ||
src.Body = io.NopCloser(&b) | ||
dest.Body = io.NopCloser(bytes.NewReader(b.Bytes())) | ||
} | ||
|
||
// copyResp copies the response body and returns a new response with the copied body. | ||
// this allows reading a response body multiple times without "closing" it. | ||
func CopyRespBody(resp *http.Response) io.ReadCloser { | ||
var b bytes.Buffer | ||
b.ReadFrom(resp.Body) | ||
resp.Body = io.NopCloser(&b) | ||
return io.NopCloser(bytes.NewReader(b.Bytes())) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.