diff src/luan/modules/http/impl/NotFound.java @ 1160:4beabb087be6

add http/impl
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 05 Feb 2018 22:33:59 -0700
parents src/luan/modules/http/jetty/NotFound.java@d30d400fd43d
children 7e6f28c769a1
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/luan/modules/http/impl/NotFound.java	Mon Feb 05 22:33:59 2018 -0700
@@ -0,0 +1,29 @@
+package luan.modules.http.impl;
+
+import luan.webserver.Request;
+import luan.webserver.Response;
+import luan.webserver.Handler;
+
+
+public class NotFound implements Handler {
+	private final Handler handler;
+
+	public NotFound(Handler handler) {
+		this.handler = handler;
+	}
+
+	@Override public Response handle(Request request) {
+		Response response = handler.handle(request);
+		if( response == null ) {
+			String path = request.path;
+			try {
+				request.path = "/not_found";
+				response = handler.handle(request);
+			} finally {
+				request.path = path;
+			}
+		}
+		return response;
+	}
+
+}