GoRequest - Simplified HTTP client ( inspired by nodejs SuperAgent )

980 views
Skip to first unread message

Theeraphol Wattanavekin

unread,
May 26, 2014, 4:18:09 AM5/26/14
to golan...@googlegroups.com
Hi,

I made a http client library called "GoRequest"(https://github.com/parnurzeal/gorequest) and want to share it here.

If you know and have used superagent library in node.js, you will feel lots like home.
If not, I still can tell you that its usage is very simple and easy.

For example, if you want to send Get method, you can do by just
request := gorequest.New()
resp, body, errs := request.Get("http://example.com/").End()

For JSON body request, it is super easy than doing json marshalling yourself because gorequest already does it for you!

request := gorequest.New()
resp, body, errs := request.Post("http://example.com").
  Set("Notes","gorequst is coming!").
  Send(`{"name":"backy", "species":"dog"}`).
  End()

Lastly, it is supporting many features such as Proxy, Timeout, etc. and I am trying to add more.


Feel free to comment. I am very active and really want opinions to improve it even more.

Thanks,

Theeraphol

Dobrosław Żybort

unread,
May 26, 2014, 7:38:44 AM5/26/14
to golan...@googlegroups.com
Nice library, thank you for creating it.

Chaining looks more appealing to me than struct in github.com/franela/goreq

Just some random ideas:

Maybe you could add option for retrying on errors? Something similar to what fvbock/gorequests have:
http://godoc.org/github.com/fvbock/gorequests#Retry

I think building query string by struct is also a nice idea:
https://github.com/franela/goreq#get

Cookies?

Best regards


Other similar packages you can check for some more feature/implementation ideas:
https://github.com/franela/goreq
https://github.com/fvbock/gorequests
https://github.com/gorilla/http (closer to std `net/http` with additional features like connection rate limiting)
https://github.com/gosexy/rest

Theeraphol Wattanavekin

unread,
May 26, 2014, 7:51:16 PM5/26/14
to Dobrosław Żybort, golan...@googlegroups.com
Wow! Thanks for great details and opinions.
These are really useful for me.

And yeah, Cookies is in a plan.
Retry and query string builder also seems to be very nice that I will try to see and include them in GoRequest soon or later :)

Regards,
Theeraphol


--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/Pqu94CxcJ24/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Theeraphol Wattanavekin

unread,
Jun 14, 2014, 9:15:42 AM6/14/14
to golan...@googlegroups.com, matr...@gmail.com
Hi again,

Just to inform that GoRequest now supports a new nice way to Send request by taking struct type as a parameter.
So, you can have more fun mix & match with json or query string in sending a request:
type BrowserVersionSupport struct {
  Chrome string
  Firefox string
}
ver := BrowserVersionSupport{ Chrome: "37.0.2041.6", Firefox: "30.0" }
request := gorequest.New()
resp, body, errs := request.Post("http://version.com/update")
  Send(ver).
  Send(`{"Safari":"5.1.10"}`).
  End()
Also, it now has a cute Gopher logo! :D



Please have a look at the repo!  -> https://github.com/parnurzeal/gorequest

Thanks,

Theeraphol 
To unsubscribe from this group and all its topics, send an email to golang-nuts+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages