changeset 1328:55b8210b4ec0

add MDC host
author Franklin Schmidt <fschmidt@gmail.com>
date Sat, 09 Feb 2019 21:49:42 -0700
parents b29eefad2111
children 5a39b006acd1
files src/luan/modules/http/LuanDomainHandler.java
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
diff -r b29eefad2111 -r 55b8210b4ec0 src/luan/modules/http/LuanDomainHandler.java
--- a/src/luan/modules/http/LuanDomainHandler.java	Fri Feb 08 00:45:31 2019 -0700
+++ b/src/luan/modules/http/LuanDomainHandler.java	Sat Feb 09 21:49:42 2019 -0700
@@ -1,5 +1,6 @@
 package luan.modules.http;
 
+import org.apache.log4j.MDC;
 import luan.webserver.Request;
 import luan.webserver.Response;
 import luan.webserver.Handler;
@@ -38,6 +39,12 @@
 	}
 
 	@Override public Response handle(Request request) {
-		return domainHandler.handle(request);
+		String host = (String)request.headers.get("host");
+		MDC.put("host",host);
+		try {
+			return domainHandler.handle(request);
+		} finally {
+			MDC.remove("host");
+		}
 	}
 }