Implemented middleware to handle non-rest methods.