-
-
Notifications
You must be signed in to change notification settings - Fork 414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ReqBody-like GET param parsing #30
Comments
I'm not sure query string parameters are supposed to be in a particular format. We use |
I'd prefer wrapper types: data JSONFromText a = JFT a instance FromJSON a => FromText (JSONFromText a) where And then use QueryParam "customer" (JSONFromText Customer)
|
I agree that it might be confusing, but to be fair, the POST body isn't supposed to be in a particular format either. jQuery, for example, treats get and post data in the same way. In fact, it was a little confusing to me in the beginning, that I have to Unless feature creep is a problem (in which case @thsutton's solution is workable), we could have another type ( |
Re. GET and request bodies: because GET requests usually don't take a request body as argument. I remember reading this a couple of months ago. Query string parameters do however fit your bill. Relatedly, you can easily go from a javascript object to the corresponding query string using jQuery's param. I don't really feel comfortable encoding things as JSON in the query string (at least in the main servant package), the URLs would be quite horrible to read and good old query params are the actual recommended solution for this (with one param per "field in the object"). If you want to use your suggestion, you could indeed use @thsutton's trick, but I'm not sure we should provide it out of the box in the servant packages -- unless @jkarni has a different opinion? |
I like the idea, and think we need to support this at some point. It shouldn't be hard - just another |
Yes. |
Add jsonEquality to compare JSON APIs
ReqBody
is great, it captures the whole POST body and make it available in a type. I wonder if it's intended that the same thing isn't available with GET. It would be nice if I can have a GET param that is a URL encoded JSON string converted into a type just like that. I would have used POST, but that has a vague effect on caching. Any thoughts?The text was updated successfully, but these errors were encountered: