Allow sending request and getting response
This commit is contained in:
parent
bf5416095e
commit
da40c2b669
|
@ -34,28 +34,29 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController
|
|||
##
|
||||
send_request
|
||||
##
|
||||
redirect_to panel_ask_back_end_ask_questions_path, notice: t('ask.reply_success')
|
||||
redirect_to panel_ask_back_end_ask_questions_path # , notice: t('ask.reply_success')
|
||||
end
|
||||
|
||||
def send_request
|
||||
require 'net/http'
|
||||
require 'uri'
|
||||
require 'json'
|
||||
uri = URI.parse("http://localhost/ask/back_end/ask_requests/auth_request:3000")
|
||||
@body = {
|
||||
|
||||
uri = URI.parse("http://localhost:4000/panel/ask/back_end/ask_requests/auth_request")
|
||||
|
||||
body = {
|
||||
"a" => "123",
|
||||
"b" => "456"
|
||||
}.to_json
|
||||
}
|
||||
|
||||
request = Net::HTTP::Post.new(initheader = {'Content-Type' =>'application/json'})
|
||||
request.body = @body
|
||||
http = Net::HTTP.new(uri.host, uri.port)
|
||||
request = Net::HTTP::Post.new(uri.request_uri)
|
||||
request.set_form_data(body)
|
||||
|
||||
response = Net::HTTP.start(uri.host, uri.port) do |http|
|
||||
http.request(request)
|
||||
end
|
||||
response = http.request(request)
|
||||
|
||||
puts "Response #{response.code} #{response.message}: #{response.body}"
|
||||
# flash[:notice]=response.message
|
||||
flash[:notice] = response.body
|
||||
# flash[:notice] = "Response #{response.code} #{response.message}: #{response.body}"
|
||||
end
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ class Panel::Ask::BackEnd::AskRequestsController < OrbitBackendController
|
|||
include OrbitControllerLib::DivisionForDisable
|
||||
|
||||
def auth_request
|
||||
|
||||
params.merge!({'c' => '789'})
|
||||
render :json => "#{params}"
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue