aboutsummaryrefslogtreecommitdiffstats
path: root/src/tools/HttpServerTools.hx
diff options
context:
space:
mode:
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