diff options
author | Runxi Yu <me@runxiyu.org> | 2025-03-15 17:16:05 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-03-15 17:16:05 +0800 |
commit | 0b541fefa3fbf8db830a2d4c52f3a33c20bae4c6 (patch) | |
tree | 270ce35ab28f0960487c5bdfc9bdd7347dc14222 /main.ha | |
parent | Use abort("unreachable") instead of a random comment (diff) | |
download | forge-0b541fefa3fbf8db830a2d4c52f3a33c20bae4c6.tar.gz forge-0b541fefa3fbf8db830a2d4c52f3a33c20bae4c6.tar.zst forge-0b541fefa3fbf8db830a2d4c52f3a33c20bae4c6.zip |
Serve static files
Diffstat (limited to 'main.ha')
-rw-r--r-- | main.ha | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -2,6 +2,7 @@ // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> // Adapted from template by Willow Barraco <contact@willowbarraco.fr> +use fs; use getopt; use log; use net; @@ -21,6 +22,8 @@ const usage: [_]getopt::help = [ ('c', "config", "path to configuration file") ]; +let static_fs: nullable *fs::fs = null; + export fn main() void = { const cmd = getopt::parse(os::args, usage...); defer getopt::finish(&cmd); @@ -35,6 +38,8 @@ export fn main() void = { }; }; + static_fs = os::diropen("static")!; + const server = match (http::listen(ip_addr, port, net::tcp::reuseport, net::tcp::reuseaddr)) { case let this: *http::server => yield this; |