creates a router middleware