diff options
author | Runxi Yu <me@runxiyu.org> | 2025-03-15 12:55:42 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-03-15 12:55:42 +0800 |
commit | 77e29361812c1d9cf0adb55f09218f20598643dc (patch) | |
tree | 9b52e24e3fdd2b34fc706bb2b014b89fc13a4a63 | |
parent | Properly start response headers (diff) | |
download | forge-77e29361812c1d9cf0adb55f09218f20598643dc.tar.gz forge-77e29361812c1d9cf0adb55f09218f20598643dc.tar.zst forge-77e29361812c1d9cf0adb55f09218f20598643dc.zip |
Add basic system path parsing
-rw-r--r-- | req.ha | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -30,6 +30,29 @@ fn handlereq(conn: io::handle, request: *http::request) (void | io::error | nome if (len(segments) == 1) { start_response(conn, 404, "text/plain")?; fmt::fprintln(conn, "Error: Blank system endpoint")?; + return; + }; + + switch (segments[1]) { + case "static" => + if (len(segments) == 2) { + start_response(conn, 404, "text/plain")?; + fmt::fprintln(conn, "Error: Blank static endpoint")?; + return; + }; + let fs_segments = segments[2 ..]; + for (let fs_segment .. fs_segments) { + if (strings::contains(fs_segment, "/")) { + start_response(conn, 400, "text/plain")?; + fmt::fprintln(conn, "Error: Slash found in filesystem path")?; + return; + }; + }; + start_response(conn, 501, "text/plain")?; + fmt::fprintln(conn, "Not implemented yet")?; + case => + start_response(conn, 404, "text/plain")?; + fmt::fprintln(conn, "Error: Unknown system endpoint")?; }; }; }; |