Parsing JSON Request Body & Return JSON Response With Golang
Edward Pie
341

Thanks Edward Pie for response. I’ve traced some code for request body by using httputil.DumpRequest.

When I send raw data, request body is:

{
“Username”: “avinash”,
“password”: “pasd”,
“IsAdmin”: true
}

And I can able to decode it into map[string]interface{}. But when I send form data in the request, request body is:

— — — WebKitFormBoundaryQLIHXcrBk6kj5Gd5
Content-Disposition: form-data; name=”Username”

avinash
 — — — WebKitFormBoundaryQLIHXcrBk6kj5Gd5
Content-Disposition: form-data; name=”Password”

adsf
 — — — WebKitFormBoundaryQLIHXcrBk6kj5Gd5
Content-Disposition: form-data; name=”IsAdmin”

true
 — — — WebKitFormBoundaryQLIHXcrBk6kj5Gd5 —

And I am getting panic for decoding. Not sure, where I am getting wrong.