aboutsummaryrefslogtreecommitdiffstats
path: root/src/tools/HttpServerTools.hx
blob: 980a458e793eb5e0e426132cd8c940078ab2b75b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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