forked to fix a couple of bugs with middleware and add compatibility with Docpad 6.55+