Mercurial Hosting > luan
comparison src/luan/modules/http/impl/NotFound.java @ 1167:7e6f28c769a1
better handlers
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 08 Feb 2018 19:06:31 -0700 |
parents | 4beabb087be6 |
children |
comparison
equal
deleted
inserted
replaced
1166:7ef40e1923b7 | 1167:7e6f28c769a1 |
---|---|
4 import luan.webserver.Response; | 4 import luan.webserver.Response; |
5 import luan.webserver.Handler; | 5 import luan.webserver.Handler; |
6 | 6 |
7 | 7 |
8 public class NotFound implements Handler { | 8 public class NotFound implements Handler { |
9 private final Handler handler; | 9 private final LuanHandler luanHandler; |
10 | 10 |
11 public NotFound(Handler handler) { | 11 public NotFound(LuanHandler luanHandler) { |
12 this.handler = handler; | 12 this.luanHandler = luanHandler; |
13 } | 13 } |
14 | 14 |
15 @Override public Response handle(Request request) { | 15 @Override public Response handle(Request request) { |
16 Response response = handler.handle(request); | 16 return luanHandler.handle(request,"site:/not_found.luan"); |
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 } | 17 } |
28 | 18 |
29 } | 19 } |