Last active
August 29, 2015 14:02
-
-
Save luckyruby/037f1a8180a3e3e5e70d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RequestsController < ApplicationController | |
skip_before_action :verify_authenticity_token | |
before_action :parse_xml | |
def ping | |
@response_tag = "OTA_PingRS" | |
rescue => e | |
log_error(e) | |
@error = e | |
render template: 'requests/error' | |
end | |
private | |
def log_error(e) | |
Rails.logger.error e.message | |
Rails.logger.error e.backtrace.join("\n") | |
end | |
def parse_xml | |
@msg = Nori.new.parse(request.body.read) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.application.routes.draw do | |
post 'ping' => 'requests#ping' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xml.instruct! | |
xml.tag!(@response_tag) { | |
xml.Success | |
xml.EchoData @msg["OTA_PingRQ"]["EchoData"] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment