On Tue, 21 Oct 2014 23:42:12 GMT, Domingo wrote:

I did it on my fork of vibe.d but I could not find a way to make a pull request with only that commit so here is the link for the commit (on this commit also there is some small changes to other parts that I found usefull):

https://github.com/mingodad/vibe.d/commit/7f0c91b072ccf92420c04ca28567f7cfe06d79bc

For doing a pull request, you'd have to create a branch based on upstream master for the desired commit(s) and then, if they are already committed to your local master cherry pick them into the new branch. Then on GitHub, you can select the specific branch to pull.

Regarding the implementation, I'd usually do something like this as a separate "proxy" function. Any functionality that is not strictly needed in the class/interface should ideally be kept separate.

Example:

// library function
alias HTTPServerReqestDelegate withModifiedRequest(alias MODIFIER)(HTTPServerRequestHandler handler, HTTPServerRequest req, HTTPServerResponse res)
{
	return (req, res) { MODIFIER(req); handler(req, res); }
}

// usage
void rewriteURL(HTTPServerRequest req)
{
	if (req.path.startsWith("/something/"))
		req.path = req.path[10 .. $];
}

static this()
{
    listenHTTP(router.withModifiedRequest!rewriteURL);
}

For most other functionality, the router can be used nicely for chaining by prepending a router.any("*", ...); route, but the matching would get less efficient if it had to watch for changed request paths, so that is not really an option here.