diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2018-05-02 22:28:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-02 22:28:46 +0200 |
commit | 28bd4b98004d1f3e28f8aae5039c57a53f17d7b0 (patch) | |
tree | e7f7c864a0dba8d5fcf4d3e1f5567b64155f67c7 /app/views/well_known/host_meta | |
parent | 658cbc94255a91453fbadd175cd45ad15efcbdf3 (diff) |
Serialize webfinger XML with Ox instead of Nokogiri (#7319)
25ms -> 0.5ms
Diffstat (limited to 'app/views/well_known/host_meta')
-rw-r--r-- | app/views/well_known/host_meta/show.xml.ruby | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/app/views/well_known/host_meta/show.xml.ruby b/app/views/well_known/host_meta/show.xml.ruby index 07d026471..0a6bdc322 100644 --- a/app/views/well_known/host_meta/show.xml.ruby +++ b/app/views/well_known/host_meta/show.xml.ruby @@ -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') |