explicitly parse JSON request bodies
This commit is contained in:
Родитель
006482677b
Коммит
74ce502d09
|
@ -50,6 +50,11 @@ module Chatops
|
|||
protected
|
||||
|
||||
def setup_params
|
||||
json_body.each do |key, value|
|
||||
next if params.has_key? key
|
||||
params[key] = value
|
||||
end
|
||||
|
||||
permitted_params = %i[
|
||||
action
|
||||
chatop
|
||||
|
@ -76,6 +81,14 @@ module Chatops
|
|||
self.params = params.permit(*permitted_params)
|
||||
end
|
||||
|
||||
def json_body
|
||||
hash = {}
|
||||
if request.content_type =~ %r/\Aapplication\/json\Z/i
|
||||
hash = GitHub::JSON.parse(request.raw_post) || {}
|
||||
end
|
||||
hash.with_indifferent_access
|
||||
end
|
||||
|
||||
def jsonrpc_params
|
||||
params["params"] || {}
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче