3 ms·
I'm also a Go noob. I tried writing a basic web server in Go yesterday to handle Twilio SMS callbacks. Trying to inspect the requests I was receiving was such a
by brink 8y ago
I'm also a Go noob. I tried writing a basic web server in Go yesterday to handle Twilio SMS callbacks. Trying to inspect the requests I was receiving was such a pain, I gave up and wrote the server with Sinatra. Am I missing something that's making this more difficult than it should be?
- jen20 8y ago`httputil.DumpRequest`[1] may have been helpful in this situation. If you're on a mainstream platform, the Delve debugger is fairly reasonable these days too. [1]: https://golang.org/pkg/net/http/httputil/#DumpRequest https://golang.org/pkg/net/http/httputil/#DumpRequest
- alyandon 8y agoYou were probably missing something but we all had to start someplace. :) I'm not a Go expert by any stretch of the imagination and I can tell you that almost everything you would want to know about a given request is exposed through the request object passed to your handler if you are using the standard Go http stuff.
- dcardoza 8y agoI love Go specifically for this purpose. I wrote a simple server doing exactly that with Twilio: https://github.com/dang3r/jenophone/ https://github.com/dang3r/jenophone/
- brink 8y agoThanks! I'll check it out.
- manveru 8y agoI'd say you were missing https://github.com/k0kubun/pp https://github.com/k0kubun/pp but the other tricky thing is that you can read a http.Request.Body only once unlike in Ruby. I usually use ioutil.ReadAll for that.
- workinthehead 8y agoThat's incorrect. Both languages require you to rewind the reader before you can read it a second time. You're probably just used to higher level frameworks like Sinatra or Rails that take care of it for you.