Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to specify query parameters in Yesod routes?

Tags:

haskell

yesod

I'm trying to specify queries in a rest-like manner in my yesod routes, e.g.

mkYesod "HelloWorld" [parseRoutes|
/ HomeR GET
/first/?count=#Int FirstR GET
/second/?count=#Int SecondR GET
|]

But this gives me the following error:

The function `FirstR' is applied to one argument,
but its type `Route HelloYesod' has none

But if I push that #Int back to being part of the path, it is all fine. I assume this is because the route isn't generated with a parameter?

Is there a way for me to specify that parameter in my route?

like image 789
Khanzor Avatar asked May 25 '13 14:05

Khanzor


1 Answers

No, it's not possible with the current setup, though it's an addition I've considered making in the past. The main reasons I haven't is (1) it would probably make the normal case a bit difficult to achieve, and (2) as josejuan mentions, it's often (though not always) possible to convert this into a route-based parameter.

like image 162
Michael Snoyman Avatar answered Sep 29 '22 18:09

Michael Snoyman