The function getUrlRender
is used for converting Route (HandlerSite m)
to Text
, through the use of Monads
. For instance:
routeToText :: MonadHandler m => Route (HandlerSite m) -> m Text
routeToText url = do
r <- getUrlRender
return $ r url
getTestR :: Text -> Handler Text
getTestR something = routeToText (TestR something)
But what if I want to pass in a query parameter? Could I do it without dealing directly with Text
s? Another question, could I simplify the type declaration of the function routeToText
?
I will use these urls to accomplish with a JSON API specification regarding pagination, I've created all the abstraction to work with it but I don't know how to implement a way to put a link like http://example.com/articles?page=2
in a concise way. If there is a even better way to put the link with the query parameter integrating it beautifully with the Aeson
library without converting it to Text
first, please, let me know.