From 96f9c66a1ac41f36f9fb232ebeb53063368775ab Mon Sep 17 00:00:00 2001
From: Runxi Yu <me@runxiyu.org>
Date: Sat, 15 Mar 2025 11:38:23 +0800
Subject: [PATCH] Split the request handler to req.ha

---
 main.ha | 10 ----------
 req.ha  | 13 +++++++++++++

diff --git a/main.ha b/main.ha
index 7b32b9dfa87ad2138db5f32acf153cbacd09e6eb..373f9e1534483de82e626d30199d5bbf6780105a 100644
--- a/main.ha
+++ b/main.ha
@@ -3,7 +3,6 @@ // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org>
 // Adapted from template by Willow Barraco <contact@willowbarraco.fr>
 
 use getopt;
-use htmpl;
 use log;
 use net;
 use net::dial;
@@ -16,7 +15,6 @@ use memio;
 use io;
 use fmt;
 use bufio;
-use strings;
 
 const usage: [_]getopt::help = [
 	"Lindenii Forge Server",
@@ -60,11 +58,3 @@ 		case io::error => log::println("error while handling request");
 		};
 	};
 };
-
-export fn handlereq(conn: io::handle, request: *http::request) (void | io::error | nomem | net::uri::invalid) = {
-	htmpl::write(conn, "HTTP/1.1 200 OK\r\n")?;
-	htmpl::write(conn, "Content-Type: text/html\r\n\r\n")?;
-	let segments = segments_from_path(request.target.raw_path)?;
-	defer strings::freeall(segments);
-	tp_index(conn, segments)?;
-};
diff --git a/req.ha b/req.ha
new file mode 100644
index 0000000000000000000000000000000000000000..53e9d6a9c91f3f4daa80cbea2230934346ab0b92
--- /dev/null
+++ b/req.ha
@@ -0,0 +1,13 @@
+use htmpl;
+use io;
+use net::http;
+use net::uri;
+use strings;
+
+export fn handlereq(conn: io::handle, request: *http::request) (void | io::error | nomem | uri::invalid) = {
+	htmpl::write(conn, "HTTP/1.1 200 OK\r\n")?;
+	htmpl::write(conn, "Content-Type: text/html\r\n\r\n")?;
+	let segments = segments_from_path(request.target.raw_path)?;
+	defer strings::freeall(segments);
+	tp_index(conn, segments)?;
+};

-- 
2.48.1