|
|
@@ -0,0 +1,46 @@
|
|
|
+package Trog::Routes::XML;
|
|
|
+
|
|
|
+use strict;
|
|
|
+use warnings;
|
|
|
+
|
|
|
+no warnings 'experimental';
|
|
|
+use feature qw{signatures state};
|
|
|
+
|
|
|
+use Clone qw{clone};
|
|
|
+use XML::Twig;
|
|
|
+use Trog::Config();
|
|
|
+
|
|
|
+my $conf = Trog::Config::get();
|
|
|
+
|
|
|
+our %routes = (
|
|
|
+ '/xml/version' => {
|
|
|
+ method => 'GET',
|
|
|
+ callback => \&version,
|
|
|
+ parameters => [],
|
|
|
+ },
|
|
|
+);
|
|
|
+
|
|
|
+# Clone / redact for catalog
|
|
|
+my $cloned = clone(\%routes);
|
|
|
+foreach my $r (keys(%$cloned)) {
|
|
|
+ delete $cloned->{$r}{callback}
|
|
|
+}
|
|
|
+
|
|
|
+# Note to authors, don't forget to update this
|
|
|
+sub _version () {
|
|
|
+ return '1.0';
|
|
|
+}
|
|
|
+
|
|
|
+sub version ($query) {
|
|
|
+ my $enc = XML::Twig->new(
|
|
|
+ 'pretty_print' => 'indented',
|
|
|
+ );
|
|
|
+ $enc->set_root( XML::Twig::Elt->new('version' => _version()) );
|
|
|
+ $new_xml->set_xml_version('1.0');
|
|
|
+ $new_xml->set_encoding('utf-8');
|
|
|
+
|
|
|
+ state $ret = [200, ['Content-type' => "application/xml", ETag => 'version-'._version()],[$new_xml->sprint()]];
|
|
|
+ return $ret;
|
|
|
+}
|
|
|
+
|
|
|
+1;
|