elixir-maru / maru

Elixir RESTful Framework
https://maru.readme.io
BSD 3-Clause "New" or "Revised" License
1.32k stars 85 forks source link

Request params map permissiveness #3

Closed ckampfe closed 9 years ago

ckampfe commented 9 years ago

Grape seems to allow request parameters to pass through to the params object that are not named in the params block.

Maru seems to take the other opinion, not placing request parameters in the params map that are not named in the params block.

Is there any way to have Maru allow all extra params into the params map while still enforcing the requires and optional constructs, a la Grape? I have it in my head as something like an atom passed to the params macro, maybe something like:

params :lenient do
   # constraints here
end

I'm open to trying to hack this myself, but this is my first experience with Elixir (it's really cool!), so I'm not sure really where to start (I'm guessing here).

Just curious if something like this is either possible or wanted. Thanks for your work, Maru is great!

falood commented 9 years ago

Thanks for pointing it out. I will check grape's implementation and fix it.

falood commented 9 years ago

I'm sorry it's difficult to do a integrated copy. The variable conn.params is a Map which has String type keys and I don't think convert it to atom-keys-map is a good idea. Erlang VM has restrictions on the number of Atom, so convert uncertain string by String.to_atom is evil.