summaryrefslogtreecommitdiff
path: root/bin/ultramarine
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2017-12-16 20:14:08 +0000
committerdakkar <dakkar@thenautilus.net>2017-12-16 20:26:14 +0000
commitdb1f46d1af765dfa5cca3d23a9e7246d4966ccd8 (patch)
tree408106d9678e307e411f53c1039a943b9f662cc6 /bin/ultramarine
parentfix authorisation to return Subsonic response (diff)
downloadUltramarine-db1f46d1af765dfa5cca3d23a9e7246d4966ccd8.tar.gz
Ultramarine-db1f46d1af765dfa5cca3d23a9e7246d4966ccd8.tar.bz2
Ultramarine-db1f46d1af765dfa5cca3d23a9e7246d4966ccd8.zip
rough server w/ serialisation
Diffstat (limited to 'bin/ultramarine')
-rw-r--r--bin/ultramarine46
1 files changed, 46 insertions, 0 deletions
diff --git a/bin/ultramarine b/bin/ultramarine
new file mode 100644
index 0000000..b98c358
--- /dev/null
+++ b/bin/ultramarine
@@ -0,0 +1,46 @@
+#!/usr/bin/env perl6
+use v6.d.PREVIEW;
+use Cro::HTTP::Router;
+use Cro::HTTP::Server;
+use Ultramarine::Model::Users;
+use Ultramarine::Middleware::Authentication;
+use Ultramarine::Middleware::Authorisation;
+use Ultramarine::Middleware::SetContentType;
+use Ultramarine::Serialiser::XML;
+
+sub respond(*@body) {
+ response.status = 200;
+ response.set-body(@body);
+}
+
+my $users = Ultramarine::Model::Users.new(
+ accounts=>{me=>'sesame'},
+);
+
+my $ultramarine_rest = route {
+ before Ultramarine::Middleware::Authentication.new(:$users);
+ before Ultramarine::Middleware::Authorisation;
+ after Ultramarine::Middleware::SetContentType;
+
+ get -> 'ping.view' { respond [] }
+};
+
+my $ultramarine = route {
+
+ body-serializer Ultramarine::Serialiser::XML.new;
+
+ delegate <rest *> => $ultramarine_rest;
+}
+
+my Cro::Service $um = Cro::HTTP::Server.new(
+ :host<localhost>,
+ :port<8080>,
+ application => $ultramarine,
+);
+
+$um.start;
+
+react whenever signal(SIGINT) {
+ $um.stop;
+ exit;
+}