use an enum to handle middleware flow, closes #38
update README and examples