changeset 5333:10fcfa7e62a1

mod_http_debug: Module that echos back HTTP request info for debugging Written in 2021 for debugging some reverse proxy issue on https://chat.prosody.im/
author Kim Alvefur <zash@zash.se>
date Fri, 07 Apr 2023 21:10:14 +0200
parents e0b5468aae49
children 3c51eab0afe8
files mod_http_debug/mod_http_debug.lua
diffstat 1 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_http_debug/mod_http_debug.lua	Fri Apr 07 21:10:14 2023 +0200
@@ -0,0 +1,26 @@
+local json = require "util.json"
+
+module:depends("http")
+module:provides("http", {
+		route = {
+			GET = function(event)
+				local request = event.request;
+				return {
+					status_code = 200;
+					headers = {
+						content_type = "application/json",
+					},
+					body = json.encode {
+						body = request.body;
+						headers = request.headers;
+						httpversion = request.httpversion;
+						ip = request.ip;
+						method = request.method;
+						path = request.path;
+						secure = request.secure;
+						url = request.url;
+					}
+				}
+			end;
+		}
+	})