When I get a request for a path that includes the word \'self\' I want to replace it with the user id before matching it to a URL. I tried using a middleware like this:
Why do you want to change the url, then match that new url? Why not have the url direct to the view and method you want, then work on the request.user.id like you would had you changed the url?
Perhaps another example would illustrate what you are trying to do.
(Making this an answer since I can't comment)