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

disambiguate parameters (#204) #303

Closed ocramz closed 11 months ago

ocramz commented 11 months ago

Disambiguate request parameters (#204).

jfraudeau commented 11 months ago

Nice to see these changes coming to scotty ! If I may add a comment, I'm not sure it makes sense to call next when parseParam fails for query and form parameters. I believe it would provide better errors to just return a "bad request" in these cases.

ocramz commented 11 months ago

Nice to see these changes coming to scotty ! If I may add a comment, I'm not sure it makes sense to call next when parseParam fails for query and form parameters. I believe it would provide better errors to just return a "bad request" in these cases.

@jfraudeau Could you share a permalink to where is this behaviour implemented? Thank you

jfraudeau commented 11 months ago

Sure : https://github.com/ocramz/scotty/blob/289ce9f9dc812edbeefaca0c773319d4d23a7675/Web/Scotty/Action.hs#L276

ocramz commented 11 months ago

@jfraudeau Good catch! But applying your suggestion would be a user-visible change, even though I don't know whether anybody actually relied on the current (buggy) behaviour or they simply worked around it.

jfraudeau commented 11 months ago

@ocramz I think it should be ok if the change only applies to the new formParams and queryParams

ocramz commented 11 months ago

I took a stab at it and added a few tests, @jfraudeau please take another look when you have time. Thanks!