Add 'rewrite' middleware

Closes #47 
Actual rewriting is not covered by tests. Can you please add a couple of test cases covering happy/unhappy rewriting cases and make sure the test coverage on `ProcessRequest` is 100% ?