Original path pattern available to middleware?
saibotsivad opened this issue Β· comments
Tobias Davis commented
Is there a way to grab the original pattern off the request in the middleware? Hacky solutions accepted. π
I want the middleware to know what path was matched, so something like this
import polka from 'polka'
const app = polka()
app.use((req, res, next) => {
console.log(req.matchedPath) // => "/users/:id"
})
app.get('/users/:id', (req, res) => {
// do whatever
})
Tobias Davis commented
After more digging, I realize I opened this as a Trouter issue first, which is where this discussion would need to start.