mirror of
https://github.com/internetee/registry.git
synced 2025-05-30 01:20:04 +02:00
Routes file refactored
This commit is contained in:
parent
e7405f7df4
commit
19c4106e18
2 changed files with 25 additions and 24 deletions
|
@ -1,27 +1,4 @@
|
|||
class EppConstraint
|
||||
OBJECT_TYPES = {
|
||||
domain: { domain: 'urn:ietf:params:xml:ns:domain-1.0' },
|
||||
contact: { contact: 'urn:ietf:params:xml:ns:contact-1.0' }
|
||||
}
|
||||
|
||||
def initialize(type)
|
||||
@type = type
|
||||
end
|
||||
|
||||
# creates parsed_frame, detects epp request object
|
||||
def matches?(request)
|
||||
parsed_frame = Nokogiri::XML(request.params[:raw_frame])
|
||||
|
||||
unless [:keyrelay, :poll].include?(@type)
|
||||
element = "//#{@type}:#{request.params[:action]}"
|
||||
return false if parsed_frame.xpath("#{element}", OBJECT_TYPES[@type]).none?
|
||||
end
|
||||
|
||||
request.params[:parsed_frame] = parsed_frame.remove_namespaces!
|
||||
request.params[:epp_object_type] = @type
|
||||
true
|
||||
end
|
||||
end
|
||||
require 'epp_constraint'
|
||||
|
||||
Rails.application.routes.draw do
|
||||
namespace(:epp, defaults: { format: :xml }) do
|
||||
|
|
24
lib/epp_constraint.rb
Normal file
24
lib/epp_constraint.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
class EppConstraint
|
||||
OBJECT_TYPES = {
|
||||
domain: { domain: 'urn:ietf:params:xml:ns:domain-1.0' },
|
||||
contact: { contact: 'urn:ietf:params:xml:ns:contact-1.0' }
|
||||
}
|
||||
|
||||
def initialize(type)
|
||||
@type = type
|
||||
end
|
||||
|
||||
# creates parsed_frame, detects epp request object
|
||||
def matches?(request)
|
||||
parsed_frame = Nokogiri::XML(request.params[:raw_frame])
|
||||
|
||||
unless [:keyrelay, :poll].include?(@type)
|
||||
element = "//#{@type}:#{request.params[:action]}"
|
||||
return false if parsed_frame.xpath("#{element}", OBJECT_TYPES[@type]).none?
|
||||
end
|
||||
|
||||
request.params[:parsed_frame] = parsed_frame.remove_namespaces!
|
||||
request.params[:epp_object_type] = @type
|
||||
true
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue