summary refs log tree commit diff stats
path: root/lib/Crater/Routes.rakumod
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2022-06-09 21:12:03 +0530
committerAndinus <andinus@nand.sh>2022-06-09 21:12:03 +0530
commit2085b4cac3a86d59360531d48251c8ab39dec0dd (patch)
tree53cabc820312da2abff2bbb9b44132b61302cad1 /lib/Crater/Routes.rakumod
parent48df36de5aa962b32d3313d6a9d2ace6a5fdac11 (diff)
downloadcrater-2085b4cac3a86d59360531d48251c8ab39dec0dd.tar.gz
Initial Gallery version
- Handles login, logout, simple directories.
Diffstat (limited to 'lib/Crater/Routes.rakumod')
-rw-r--r--lib/Crater/Routes.rakumod24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/Crater/Routes.rakumod b/lib/Crater/Routes.rakumod
new file mode 100644
index 0000000..6206e5c
--- /dev/null
+++ b/lib/Crater/Routes.rakumod
@@ -0,0 +1,24 @@
+use Cro::HTTP::Router;
+use Cro::WebApp::Template;
+
+use Crater::Gallery;
+use Crater::Routes::Auth;
+use Crater::Routes::Gallery;
+
+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;
+        }
+    }
+}