Diff

mod_rest/mod_rest.lua @ 4921:816b23e09c20

mod_rest: Improve logging of results from callback startup probe Especially interested in logging 500 status codes and their errors, to diagnose problems with the callback API.
author Kim Alvefur <zash@zash.se>
date Sat, 09 Apr 2022 00:43:18 +0200
parent 4920:bdac7c717c91
child 4922:c83b009b5bc5
line wrap: on
line diff
--- a/mod_rest/mod_rest.lua	Sat Apr 09 00:41:18 2022 +0200
+++ b/mod_rest/mod_rest.lua	Sat Apr 09 00:43:18 2022 +0200
@@ -435,13 +435,16 @@
 			method = "OPTIONS",
 		}, function (body, code, response)
 			if code == 0 then
-				return module:log_status("error", "Could not connect to callback URL %q: %s", rest_url, body);
-			else
+				module:log_status("error", "Could not connect to callback URL %q: %s", rest_url, body);
+			elseif code == 200 then
 				module:set_status("info", "Connected");
-			end
-			if code == 200 and response.headers.accept then
-				send_type = decide_type(response.headers.accept, supported_outputs);
-				module:log("debug", "Set 'rest_callback_content_type' = %q based on Accept header", send_type);
+				if response.headers.accept then
+					send_type = decide_type(response.headers.accept, supported_outputs);
+					module:log("debug", "Set 'rest_callback_content_type' = %q based on Accept header", send_type);
+				end
+			else
+				module:log_status("warn", "Unexpected response code %d from OPTIONS probe", code);
+				module:log("warn", "Endpoint said: %s", body);
 			end
 		end);