Implementing a custom middleware to get the request path