URI matching middleware