Add 'rewrite' middleware

Closes #47