开发者

Ruby - Get request body from incoming http call

开发者 https://www.devze.com 2022-12-27 00:26 出处:网络
I am receiving http requests to my rails application to a url /开发者_运维问答account/postback

I am receiving http requests to my rails application to a url /开发者_运维问答account/postback

The body of this incoming request contains some json that I need to retrieve, how can I do this in ruby?


The following should print the body of the request

routes.rb

map.connect 'account/:action', :controller => 'accounts'

accounts_controller.rb

class AccountsController < ApplicationController
  def postback
    puts request.body.read    
  end
end


If your HTTP call is using the POST verb you could alternatively use request.raw_post to retrieve the contents sent in the request's body.

Hope it helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消