I know that you can get the body content from
ioutil.ReadAll(c.Request.Body)
But using httputil.DumpRequest
dump, err := httputil.DumpRequest(c.Request, true)
will give the body contents along with other values, the body content in the end.
Content type: application/json IP: 127.0.0.1:36846 header token: Content length: 76 Request Method: POST Request URL: /signup Body: POST /signup HTTP/1.1 Host: 127.0.0.1:8080 Accept: / Accept-Encoding: gzip,deflate Accept-Language: en-US,en;q=0.8 Connection: keep-alive Content-Type: application/json Origin: chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.101 Safari/537.36 {"fname":"aFirstName", "lname":"aLName", "email":"test@test.com", "password":"123"}
Is there an efficient way I can get only the body content from httputil.DumpRequest()? i.e In this case only
{"fname":"aFirstName", "lname":"aLName", "email":"test@test.com", "password":"123"}