Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
grid5000
g5k-api
Commits
510ab23c
Commit
510ab23c
authored
Oct 27, 2020
by
Samir Noir
🧀
Browse files
Remove useless parse_json_payload method
Rails already had the parsed payload to params
parent
caee9f1c
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/controllers/application_controller.rb
View file @
510ab23c
...
...
@@ -20,7 +20,6 @@ class ApplicationController < ActionController::Base
protect_from_forgery
unless:
->
{
request
.
format
.
json?
}
before_action
:lookup_credentials
before_action
:parse_json_payload
,
only:
%i[create update destroy]
before_action
:set_default_format
# additional classes introduced to handle all possible exceptions
...
...
@@ -177,16 +176,6 @@ class ApplicationController < ActionController::Base
end
end
# Automatically parse JSON payload when request content type is JSON
def
parse_json_payload
if
request
.
content_type
=~
%r{application/.*json}i
json
=
JSON
.
parse
(
request
.
body
.
read
)
params
.
merge!
(
json
)
end
ensure
request
.
body
.
rewind
end
def
render_error
(
exception
,
options
=
{})
log_exception
(
exception
)
message
=
options
[
:message
]
||
exception
.
message
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment