comparison 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
comparison
equal deleted inserted replaced
1159:3ef883468fd0 1160:4beabb087be6
1 package luan.modules.http.impl;
2
3 import luan.webserver.Request;
4 import luan.webserver.Response;
5 import luan.webserver.Handler;
6
7
8 public class NotFound implements Handler {
9 private final Handler handler;
10
11 public NotFound(Handler handler) {
12 this.handler = handler;
13 }
14
15 @Override public Response handle(Request request) {
16 Response response = handler.handle(request);
17 if( response == null ) {
18 String path = request.path;
19 try {
20 request.path = "/not_found";
21 response = handler.handle(request);
22 } finally {
23 request.path = path;
24 }
25 }
26 return response;
27 }
28
29 }