1160
|
1 package luan.modules.http.impl;
|
377
|
2
|
1160
|
3 import luan.webserver.Request;
|
|
4 import luan.webserver.Response;
|
|
5 import luan.webserver.Handler;
|
377
|
6
|
|
7
|
1160
|
8 public class NotFound implements Handler {
|
|
9 private final Handler handler;
|
377
|
10
|
1160
|
11 public NotFound(Handler handler) {
|
|
12 this.handler = handler;
|
377
|
13 }
|
|
14
|
1160
|
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;
|
377
|
27 }
|
|
28
|
|
29 }
|