cjoudrey / gluahttp

gluahttp: an http module for gopher-lua
MIT License
59 stars 23 forks source link

add access jsonBody in http.Post() #18

Closed xiaoyao closed 8 years ago

xiaoyao commented 8 years ago

Hi, many thanks for your excellent work in helpfull gluahttp. It's my first pr... excited!

It adds access to jsonBody(type: string) in http.Post(), so we can post a json object in string.

erikdubbelboer commented 8 years ago

To be honest I think a much much cleaner solution would be to move the headers handling at gluahttp.go#L141-L145 to the bottom of the containing if statement. This way the other options don't overwrite these custom headers. This would allow you to fill form with your encoded JSON and use headers to set your own specific Content-Type header (in this case application/json). This would allow for many more cases than just JSON and prevents us from in the future having to another option called xmlBody or ...Body.

@cjoudrey what do you think?

xiaoyao commented 8 years ago

That's it. You are right. It's such a terrible pr. Please don't stop me from laugh at it ^_^

erikdubbelboer commented 8 years ago

@dongkui0712 No it's not terrible at all. Your code could definitely work and your pull request was better than many others I have seen. You even wrote a test. I didn't want to discourage you on your first pull request as I can clearly see you're a good programmer.

xiaoyao commented 8 years ago

@erikdubbelboer Your words are encouraging. Thanks a lot. Have a nice day