Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create HttpClientModule to handle HTTP request from another web server #61

Closed
panzhangwang opened this issue Jun 4, 2013 · 9 comments
Closed
Assignees
Milestone

Comments

@panzhangwang
Copy link

No description provided.

@ldaley
Copy link
Member

ldaley commented Jun 4, 2013

Can you add some more detail about what you want to do please.

@panzhangwang
Copy link
Author

I need write HttpClient to talk a remote server from Ratpack. I think it is a decent way to have it in Ratpack core. Otherwise, I could make use of HttpComponents, http://hc.apache.org/httpcomponents-client-ga/

@ldaley
Copy link
Member

ldaley commented Jun 4, 2013

I'm not sure about having it in the core. Ratpack is never going to have every feature as it's intended to be light.

It might happen one day, but it's pretty far down on the list of priorities so isn't likely to happen anytime soon. You might be better rolling your own.

There's not that much Ratpack integration that you'll need. You'll really just want to pack it up in Guice module.

Also, you may want to look at http://vertx.io as it provides this out of the box.

@panzhangwang
Copy link
Author

Agree. However, after introducing Vert.x jar, my app goes fat. My code as below:

def client = Vertx.newVertx().createHttpClient()
def req = client.post('/post', { resp ->
body = new Buffer()
resp.dataHandler { d ->
body << d
}
esp.endHandler {
response.send "application/json", toJson("")
}
})

FYI. It is a common case to have HTTP/Rest client for integration purpose because every RESTful app wants to stay cool and thin. Some of tools are below:

  1. http://vertx.io/api/java/api/org/vertx/java/core/http/HttpClient.html
    pros: aync, Netty
    cons: not light enough, need vert.x core and vert.x lang-groovy
  2. https://github.com/AsyncHttpClient/async-http-client
    pros: async, Netty
    cons: no support for groovy closure
  3. http://groovy.codehaus.org/HTTP+Builder,
    cons:easy, both sync and async, HttpComponets based
    cons: too much dependencies, groovy 1.8

@ldaley
Copy link
Member

ldaley commented Jun 5, 2013

I originally meant that you could use Vertx instead of Ratpack entirely.

Might be worth checking out: https://github.com/jwagenleitner/groovy-wslite

I'm starting to think it might be worth looking into something in core at some point, so the event loop can be shared. This is only really a concern in very high scale apps though.

@panzhangwang
Copy link
Author

I like chain of handlers in Ratpack and I may use Ratpack on the front end and has some request to redirect to backend applications, say Grails. So, I would see the possibility to have Ratpack as a client.

@msgilligan
Copy link

Wouldn't it be a good idea for any outbound HTTP requests to be made with Netty? Is there a Netty lib that could be used for this?

@ldaley
Copy link
Member

ldaley commented Aug 28, 2013

There aren't any practically usable http clients built on Netty. Netty is too low level to use as a general purpose API client.

@ldaley
Copy link
Member

ldaley commented Dec 29, 2013

Superseded by #217.

@ldaley ldaley closed this as completed Dec 29, 2013
@ghost ghost assigned ldaley Dec 30, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants