diff options
| author | Remi <6680627+riseremi@users.noreply.github.com> | 2025-04-07 19:58:46 +0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-07 17:58:46 +0300 |
| commit | f61717fcc48fe7039cab5e183da29653e445f691 (patch) | |
| tree | b1c03132d9e76554f898b82c02a5987e40388917 /src/tools/HttpServerTools.hx | |
| parent | f874dcd3de368e7e512ab1c0defdd17bc3026ce5 (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.hx | 22 |
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(); + } +} |
