perwendel/spark — pull request #14 by Arnauld (2012-03-02 23:10:48+00:00)
Title: Tests fix + New Feature proposal: *around* route

Hi,
Thanks for your job and congratulation, it is really nice, simple and effective!

Here are some changes:

* add `Lifecycle` in order to register listeners to track server start
* make sure tests wait for server to be started before starting using a `latch` relying on the `Lifecycle` generic approach
* add interceptor to allow an "around" routing e.g.:

Spark.around(new Interceptor() {
@Override
public void handle(Request request, Response response, InterceptorChain chain) {
long t0 = System.currentTimeMillis();
// invoke next interceptor or the target
chain.invokeNext();
long t1 = System.currentTimeMillis();
LOG.info(Request handled in " + (t1 - t0) + "ms");
}
});