mirror of
https://github.com/simon-ding/polaris.git
synced 2026-03-07 01:50:47 +08:00
25 lines
435 B
Go
25 lines
435 B
Go
package tools
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"net/http"
|
|
"net/http/httputil"
|
|
)
|
|
|
|
// PrintResponse prints the body of a response
|
|
func PrintResponse(body io.ReadCloser) {
|
|
r, _ := io.ReadAll(body)
|
|
fmt.Println("response: " + string(r))
|
|
}
|
|
|
|
// PrintRequest prints a request
|
|
func PrintRequest(req *http.Request) error {
|
|
r, err := httputil.DumpRequest(req, true)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
fmt.Println("request: " + string(r))
|
|
return nil
|
|
}
|