Created
January 18, 2015 07:32
-
-
Save nabeken/6e70096e399b9020a664 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// +build debug | |
package queue | |
import ( | |
"bytes" | |
"io/ioutil" | |
"log" | |
"net/http" | |
"github.com/motemen/go-loghttp" | |
_ "github.com/motemen/go-loghttp/global" | |
) | |
func init() { | |
loghttp.DefaultLogRequest = func(req *http.Request) { | |
body, _ := ioutil.ReadAll(req.Body) | |
defer req.Body.Close() | |
req.Body = ioutil.NopCloser(bytes.NewReader(body)) | |
log.Printf("---> %s %s\n%s\n", req.Method, req.URL, body) | |
} | |
loghttp.DefaultLogResponse = func(resp *http.Response) { | |
body, _ := ioutil.ReadAll(resp.Body) | |
defer resp.Body.Close() | |
resp.Body = ioutil.NopCloser(bytes.NewReader(body)) | |
log.Printf("<--- %d %s\n%s\n", resp.StatusCode, resp.Request.URL, body) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment