scotty-web / scotty

Haskell web framework inspired by Ruby's Sinatra, using WAI and Warp (Official Repository)
http://hackage.haskell.org/package/scotty
BSD 3-Clause "New" or "Revised" License
1.72k stars 134 forks source link

Get matched route in ActionM using `capture` #266

Open kt0d opened 4 years ago

kt0d commented 4 years ago

When using regex to match a route, I am able to later retrieve matched path with param "0", as in example described here:

https://hackage.haskell.org/package/scotty-0.12/docs/Web-Scotty.html#v:regex

Can this be done if I match a route using capture?

jfraudeau commented 11 months ago

It's not possible in the current state of things. As the original pattern is turned into a WAI middleware, see : https://github.com/scotty-web/scotty/blob/dc66aa082808b7a9884d748e1a86a8e491c67e32/Web/Scotty/Route.hs#L86-L108

It should be possible to add the orignal pattern to ActionEnv

What do you think @ocramz ? This could be a nice new feature, I could see myself using it for logging and metrics metadata

ocramz commented 11 months ago

Agreed this would be nice to have !