add middleware support, examples, update readme and add tests