Modular middleware and route handling