Software /
code /
prosody-modules
Diff
mod_rest/mod_rest.lua @ 3861:ede3d1724dd1
mod_rest: Attempt to auto-discover data type wanted by callback
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 25 Jan 2020 20:04:39 +0100 |
parent | 3858:29c39876c4af |
child | 3862:3b6b8dcff78e |
line wrap: on
line diff
--- a/mod_rest/mod_rest.lua Sat Jan 25 02:06:07 2020 +0100 +++ b/mod_rest/mod_rest.lua Sat Jan 25 20:04:39 2020 +0100 @@ -153,6 +153,15 @@ send_type = "application/json"; end + http.request(rest_url, { + method = "OPTIONS", + }, function (body, code, response) + if code == 200 and response.headers.accept then + send_type = decide_type(response.headers.accept); + module:log("debug", "Set 'rest_callback_content_type' = %q based on Accept header", send_type); + end + end); + local code2err = { [400] = { condition = "bad-request"; type = "modify" }; [401] = { condition = "not-authorized"; type = "auth" };