shenfeng/http-kit — pull request #5 by ptaoussanis (2013-01-11 10:12:43+00:00)
Title: BREAKING, UNTESTED: further API experimentation

Okay I took a quick stab at this, basing off of your last `client` branch. I've got some other work I need to finish today, so this was done in a bit of a hurry - there are probably errors, but I just wanted to get your input on the general idea/direction.

Major changes:
* Simplified the client handling. This assumes that `HttpClientConfig` will be dropped in favor of per-request :timeout and :user-agent config.
* Added a low-level `request*` function. Takes a callback, otherwise returns a response promise (so it's asynchronous either way). I'd still like some more time to think about this, but the idea is to try and make as few assumptions as possible about how to handle the response pipeline.
* Added a higher-level `request` macro that wraps `request*` with some conveniences like error handling, response destructuring, and an explicit `async?` switch. When `:async?` is on (default), `request` behaves synchronously (it'll block for a response, and return that response). When `:async?` is off, the `handler-forms` is used as an asynchronous callback. I think this is cleaner than needing a special `async` macro.
* I believe the promise form of `request*` could be used to implement your `select` macro (I've renamed it `first-resp` here).

If you like the general idea, I'll clean this up:
* Need to test it properly. Probably errors to be ironed out.
* Finish up the docstrings.
* Update the README examples.

I have a couple questions - please see the TODO at the top of client.clj.