On Tue, 19 Mar 2013 07:44:01 +0100
Sönke Ludwig sludwig@rejectedsoftware.com wrote:

If you are using UrlRouter, you can already do that like this:

auto router = new UrlRouter;
router.any("*", &performOnAllRequests);
router.get("/", &showIndexPage);
// ...

If performOnAllRequests doesn't write a response, the router will
continue to match the request against the following routes until some
of them actually writes something or throws an exception.

Another possibility is calling listenHttp with a delegate that does
the special request handling and then call router.handleRequest(req,<br>res) to continue with the usual route matching.

Ah, ok, I didn't realize any of that. Sounds good.

But in that form it would mean that the response body needs to stay in
memory and even if r.content is replaced by some kind of callback or
stream it would mean that there is at least one GC allocation.
Avoiding memory allocations is the main reason why the current
interface is like it is.

While I agree that this is a good interface for certain applications,
what I'm struggling a bit with is including multiple ways to achieve
the same thing in the library... while I have to admit that there are
already some high level things, the plan was rather to keep vibe.d
itself basic and to the point (the reason why it contains those things
is mainly because dub didn't exist yet and it would have made the
build process for certain projects more complex, but they will become
separate packages at some point).

Btw. instead of

if(blah){
	httpNotFound(res);
	return;
}

this also works right now:

if(blah) throw new HttpStatusException(HttpStatus.notFound);

or shorter

enforceHttp(!blah, HttpStatus.notFound);



Hmm. I see.