Software /
code /
prosody-modules
Comparison
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 |
comparison
equal
deleted
inserted
replaced
4920:bdac7c717c91 | 4921:816b23e09c20 |
---|---|
433 module:set_status("info", "Not yet connected"); | 433 module:set_status("info", "Not yet connected"); |
434 http.request(get_url(st.stanza("meta", { type = "info", to = module.host, from = module.host })), { | 434 http.request(get_url(st.stanza("meta", { type = "info", to = module.host, from = module.host })), { |
435 method = "OPTIONS", | 435 method = "OPTIONS", |
436 }, function (body, code, response) | 436 }, function (body, code, response) |
437 if code == 0 then | 437 if code == 0 then |
438 return module:log_status("error", "Could not connect to callback URL %q: %s", rest_url, body); | 438 module:log_status("error", "Could not connect to callback URL %q: %s", rest_url, body); |
439 elseif code == 200 then | |
440 module:set_status("info", "Connected"); | |
441 if response.headers.accept then | |
442 send_type = decide_type(response.headers.accept, supported_outputs); | |
443 module:log("debug", "Set 'rest_callback_content_type' = %q based on Accept header", send_type); | |
444 end | |
439 else | 445 else |
440 module:set_status("info", "Connected"); | 446 module:log_status("warn", "Unexpected response code %d from OPTIONS probe", code); |
441 end | 447 module:log("warn", "Endpoint said: %s", body); |
442 if code == 200 and response.headers.accept then | |
443 send_type = decide_type(response.headers.accept, supported_outputs); | |
444 module:log("debug", "Set 'rest_callback_content_type' = %q based on Accept header", send_type); | |
445 end | 448 end |
446 end); | 449 end); |
447 | 450 |
448 local code2err = require "net.http.errors".registry; | 451 local code2err = require "net.http.errors".registry; |
449 | 452 |