I wish to store this string payload in a DB, and then construct a multipart request from this, and make one.
On Sunday, July 10, 2016 at 6:41:17 PM UTC+5:30, Egon wrote: > > Not quite sure what you mean by reconstructing the request. There is > https://golang.org/pkg/mime/multipart/ for parsing MIME multipart. > > On Sunday, 10 July 2016 15:39:00 UTC+3, Mayank Jha wrote: >> >> Any clues people ? >> >> On Thursday, July 7, 2016 at 5:05:13 PM UTC+5:30, Mayank Jha wrote: >>> >>> I have the payload, >>> "--------------------------3c1e04950334427b >>> Content-Disposition: form-data; name="certificate"; >>> filename="new-cert.pem" >>> Content-Type: application/octet-stream >>> >>> -----BEGIN RSA PRIVATE KEY----- >>> <MY PRIVATE KEY> >>> -----END RSA PRIVATE KEY----- >>> -----BEGIN CERTIFICATE----- >>> <MY CERTIFICATE> >>> -----END CERTIFICATE----- >>> >>> --------------------------3c1e04950334427b >>> Content-Disposition: form-data; name="body" >>> Content-Type: application/json >>> >>> {"name":"test"} >>> --------------------------3c1e04950334427b--" which I obtained by doing, >>> >>> //Here r is a *http.Request. object >>> >>> body := new(bytes.Buffer) >>> if r.Body != nil { >>> b, _ := ioutil.ReadAll(r.Body) >>> r.Body = ioutil.NopCloser(bytes.NewBuffer(b)) >>> if len(b) > 0 { >>> if err := json.Compact(body, b); err != nil { >>> body = bytes.NewBuffer(b) >>> } >>> } >>> } >>> >>> payload := body.String() >>> >>> >>> I want to reconstruct the request from this payload, how can I do that ? >>> Is that possible ? If yes, how ? >>> >>> >>> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.