Diff

mod_rest/mod_rest.lua @ 3873:fea0c1bed1a0

mod_rest: Back out 513a8a7fab41 I see the mistake now > if true or ...
author Kim Alvefur <zash@zash.se>
date Tue, 04 Feb 2020 20:19:09 +0100
parent 3872:513a8a7fab41
child 3874:505ae524b635
line wrap: on
line diff
--- a/mod_rest/mod_rest.lua	Mon Feb 03 23:09:38 2020 +0100
+++ b/mod_rest/mod_rest.lua	Tue Feb 04 20:19:09 2020 +0100
@@ -315,19 +315,17 @@
 	end
 end
 
-if module:get_option_boolean("rest_json_errors", false) then
-	local http_server = require "net.http.server";
-	module:hook_object_event(http_server, "http-error", function (event)
-		local request, response = event.request, event.response;
-		if true or decide_type(request and request.headers.accept or "") == "application/json" then
-			if response then
-				response.headers.content_type = "application/json";
-			end
-			return json.encode({
-					type = "error",
-					error = event.error,
-					code = event.code,
-				});
+local http_server = require "net.http.server";
+module:hook_object_event(http_server, "http-error", function (event)
+	local request, response = event.request, event.response;
+	if true or decide_type(request and request.headers.accept or "") == "application/json" then
+		if response then
+			response.headers.content_type = "application/json";
 		end
-	end, 10);
-end
+		return json.encode({
+				type = "error",
+				error = event.error,
+				code = event.code,
+			});
+	end
+end, 10);