Serialize webfinger XML with Ox instead of Nokogiri (#7319)

25ms -> 0.5ms
This commit is contained in:
Eugen Rochko
2018-05-02 22:28:46 +02:00
committed by GitHub
parent 658cbc9425
commit 28bd4b9800
3 changed files with 56 additions and 17 deletions

View File

@ -1,5 +1,13 @@
Nokogiri::XML::Builder.new do |xml|
xml.XRD(xmlns: 'http://docs.oasis-open.org/ns/xri/xrd-1.0') do
xml.Link(rel: 'lrdd', type: 'application/xrd+xml', template: @webfinger_template)
doc = Ox::Document.new(version: '1.0')
doc << Ox::Element.new('XRD').tap do |xrd|
xrd['xmlns'] = 'http://docs.oasis-open.org/ns/xri/xrd-1.0'
xrd << Ox::Element.new('Link').tap do |link|
link['rel'] = 'lrdd'
link['type'] = 'application/xrd+xml'
link['template'] = @webfinger_template
end
end.to_xml
end
('<?xml version="1.0" encoding="UTF-8"?>' + Ox.dump(doc, effort: :tolerant)).force_encoding('UTF-8')