dispatch/dispatch — pull request #62 by daros (2011-12-13 17:54:24+00:00)
Title: JSoup and TagSoup modules for processing real world HTML

There are two issues with this pull request:

1: The JSoupHandlers takes a Request (class JSoupHandlers(request: Request)) not a HandlerVerbs
I have not been able to figure out how to both reuse the '>>' handler verb and make the request available inside the block.
JSoup need the baseURI internally to be able to resolve links to absolute path from the HTML document.
When using the Request as input parameter for the JSoupHandlers class the '>>' verb can be reused and the baseUri can be extracted. However, this makes the implicit conversions a little less convenient since I have to use parenthesis to separate the Request part from the handler verb part.
example:
```val result = Http((:/("example.org") / "test.html") \\> {doc => doc})
```

I don't think this is a big problem, it is caught by type checking, but if a better solution can be found (allowing implicit conversion from HandlerVerbs instead) it would be better.

Serving test resources
-------------------------------
I ended up using Jetty to serve my test pages. I looked into using Netty, but why invent the wheel again, Jetty already has this embedded server stuff figured out in a solid solution, so I went with the beast I know :)

And now the second issue:

2: I don't know where to put the generic and reusable test trait "ServedByJetty" so that it is available to tests for several modules.
The trait does this:
a) starts a server
b) runs a test that need a resource served by the server
c) stop the server
It is only used by the tests, and the Jetty dependency is scoped to test.
As for now I have included the exact same code it in both the JSoup and TagSoup module.

It is always tricky how to handle code needed as a test dependency by more than one module and still not expose it in the distribution.

/Best Regards
David Rosell