summary refs log tree commit diff stats
path: root/lib/Crater/Routes.rakumod
blob: 1400acf174716bd5ec0b438672edcd452aa5a704 (plain) (blame)
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
use Cro::HTTP::Router;
use Cro::WebApp::Template;

use Crater::Gallery;
use Crater::Routes::Auth;
use Crater::Routes::Gallery;

#| routes contains all routes. This block may contain unauthenticated
#| paths.
sub routes(
    Crater::Gallery :$gallery!, #= gallery object
    Str :$password!, #= password for authentication
) is export {
    template-location 'templates/';
    route {
        after { redirect '/login', :see-other if .status == 401 };

        include auth-routes(:$password);
        include gallery-routes(:$gallery);

        get -> 'resources', 'css', *@path {
            static 'resources', 'css', @path;
        }
        get -> 'resources', 'js', *@path {
            static 'resources', 'js', @path;
        }
    }
}