aboutsummaryrefslogtreecommitdiffstats
path: root/src/tools/HttpServerTools.hx
diff options
context:
space:
mode:
authorRemi <6680627+riseremi@users.noreply.github.com>2025-04-07 19:58:46 +0500
committerGitHub <noreply@github.com>2025-04-07 17:58:46 +0300
commitf61717fcc48fe7039cab5e183da29653e445f691 (patch)
treeb1c03132d9e76554f898b82c02a5987e40388917 /src/tools/HttpServerTools.hx
parentf874dcd3de368e7e512ab1c0defdd17bc3026ce5 (diff)
Ask to create admin user on fresh install (#62)
* Ask to create admin user on fresh install * Implement client form submitting * minimize diff, simplify impl * Check json typing and clean stuff --------- Co-authored-by: RblSb <msrblsb@gmail.com>
Diffstat (limited to 'src/tools/HttpServerTools.hx')
-rw-r--r--src/tools/HttpServerTools.hx22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/tools/HttpServerTools.hx b/src/tools/HttpServerTools.hx
new file mode 100644
index 0000000..980a458
--- /dev/null
+++ b/src/tools/HttpServerTools.hx
@@ -0,0 +1,22 @@
+package tools;
+
+import haxe.Json;
+import js.node.http.ServerResponse;
+
+class HttpServerTools {
+ public static function status(res:ServerResponse, status:Int):ServerResponse {
+ res.statusCode = status;
+ return res;
+ }
+
+ public static function json(res:ServerResponse, obj:Any):ServerResponse {
+ res.setHeader("content-type", "application/json");
+ res.end(Json.stringify(obj));
+ return res;
+ }
+
+ public static function redirect(res:ServerResponse, url:String):Void {
+ res.writeHead(302, {"location": url});
+ res.end();
+ }
+}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage