Fetch payload body from params[:notification]
What does this MR do?
Related to the Generic Alert Endpoint.
Fetch payload body from params[:notification]
instead of slicing out service params such as controller, and action names.
If the "Content-Type" header of your request is set to "application/json", Rails will automatically load your parameters into the params hash, which you can access as you would normally.
https://guides.rubyonrails.org/v5.2/action_controller_overview.html#json-parameters
Request example
→ curl --request POST --data '{"title": "Incident title"}' --header "Authorization: Bearer randomtoken" --header "Content-Type: application/json" http://localhost:3000/ck3g/playground/alerts/notify
<ActionController::Parameters {"title"=>"Incident title", "controller"=>"projects/alerting/notifications", "action"=>"create", "namespace_id"=>"ck3g", "project_id"=>"playground", "notification"=>{"title"=>"Incident title"}} permitted: false>
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation created/updated or follow-up review issue created -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Performance and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
~~Label as security and @ mention @gitlab-com/gl-security/appsec
~~ -
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Edited by Vitali Tatarintev