Allow param transformation with transproc #30
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A new
:params
extension has been added (which in turns removes#params
implementation from:url
extension).This new extension adds a
Conn#params
method which can perform any number of transformations to the request parameters.When no transformations are given,
#params
just returns request parameters (both GET and POST) as a hash:Further processing can be specified thanks to
transproc
gem (you need to add it yourself to the Gemfile). All hash transformations intransproc
are available:Extra needed arguments can be provided as an array:
Instead of injecting transformations at the moment
#params
is called, you can configure them to be automatically used.You can register your own transformation functions:
Your own transformation functions can depend on the
Conn
instance at the moment of execution. For that, just place it as the last argument of the function and it will be curried automatically:Inline transformations can also be provided:
Besides, router params has also been removed from
:url
extension and it is now a standalone extension called:router_params
.This extension adds a
:router_params
transformation to merge router params intoConn#params
.