add sending post request function
This commit is contained in:
parent
cd26b880fb
commit
d98d008806
|
@ -17,6 +17,11 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController
|
||||||
if @ask_question.ask_reply.send_email?
|
if @ask_question.ask_reply.send_email?
|
||||||
Resque.enqueue(SendAskReplyMail, @ask_reply.ask_question.id)
|
Resque.enqueue(SendAskReplyMail, @ask_reply.ask_question.id)
|
||||||
end
|
end
|
||||||
|
##
|
||||||
|
##if status == "..."
|
||||||
|
##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')
|
redirect_to panel_ask_back_end_ask_questions_path, notice: t('ask.reply_success')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -26,6 +31,32 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController
|
||||||
if @ask_reply.send_email?
|
if @ask_reply.send_email?
|
||||||
Resque.enqueue(SendAskReplyMail, @ask_reply.ask_question.id)
|
Resque.enqueue(SendAskReplyMail, @ask_reply.ask_question.id)
|
||||||
end
|
end
|
||||||
|
##
|
||||||
|
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
|
end
|
||||||
|
|
||||||
|
def send_request
|
||||||
|
require 'net/http'
|
||||||
|
require 'uri'
|
||||||
|
require 'json'
|
||||||
|
uri = URI.parse("http://localhost:3000")
|
||||||
|
@body = {
|
||||||
|
"a" => "123",
|
||||||
|
"b" => "456"
|
||||||
|
}.to_json
|
||||||
|
|
||||||
|
request = Net::HTTP::Post.new(initheader = {'Content-Type' =>'application/json'})
|
||||||
|
request.body = @body
|
||||||
|
|
||||||
|
response = Net::HTTP.start(uri.host, uri.port) do |http|
|
||||||
|
http.request(request)
|
||||||
|
end
|
||||||
|
|
||||||
|
puts "Response #{response.code} #{response.message}: #{response.body}"
|
||||||
|
# flash[:notice]=response.message
|
||||||
|
# flash[:notice] = "Response #{response.code} #{response.message}: #{response.body}"
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue