-
Notifications
You must be signed in to change notification settings - Fork 6
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
Added shared_params
helper
#5
base: develop
Are you sure you want to change the base?
Conversation
@@ -14,6 +14,7 @@ API is an important part of web applications. They provide interfaces for commun | |||
* Each API resource class (e.g. `UsersResource`) defines a single resource (e.g. `resource :users do ... end`). | |||
* Entities are stored in `entities/` directory and inherited from `Grape::Entity` class. | |||
* Each API resource, entity class or helpers module class are wrapped into corresponding module (e.g. `AppV1API::Resources`, `AppV1API::Entities`, `AppV1API::Helpers`). | |||
* For duplicate params across the project use special `SharedParamsHelper` helper. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This sentence is not very English ;)
- It is useful for sharing params between several API resources. If params are shared between "actions" of the same resources then it is better to keep them inside the resource.
Probbly, something like this will sound a bit better:
"SharedParamsHelper
helper may be used to share params between resources."
extend Grape::API::Helpers | ||
|
||
params :user do | ||
# List of API params, for reusing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
,
is not needed.
|
||
resource :user do | ||
params do | ||
use :user # Call `params` which set at SharedParamsHelper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Call -> invokes
- which set - > which is defined
No description provided.