summaryrefslogtreecommitdiff
path: root/bin/ultramarine
blob: 07cd86990f30802527aef05a7df4b57d121ad5c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env perl6 
use v6.d.PREVIEW;
use Ultramarine::Model::License;
use Ultramarine::Model::Users;
use Ultramarine::Middleware::Authentication;
use Ultramarine::Middleware::Authorisation;
use Ultramarine::Middleware::SetContentType;
use Ultramarine::Serialiser::XML;
use Ultramarine::Serialiser::JSON;
use Ultramarine::Controller;
use Ultramarine::Server;
 
my $users = Ultramarine::Model::Users.new(
    accounts=> { me => 'sesame' },
);
my $controller = Ultramarine::Controller.new(
    license => Ultramarine::Model::License.new,
    authorisation => Ultramarine::Middleware::Authorisation.new,
).routes;
 
my $server = Ultramarine::Server.new(
    :host<192.168.1.145>,
    :port<8080>,
    :$controller,
    authentication => Ultramarine::Middleware::Authentication.new(:$users),
    serialisers => [
                    Ultramarine::Serialiser::XML.new,
                    Ultramarine::Serialiser::JSON.new,
                ],
    set-content-type => Ultramarine::Middleware::SetContentType.new,
    do-trace => True,
).server;
 
$server.start;
 
say "ready";
 
react whenever signal(SIGINT{
    $server.stop;
    exit;
}