Mercurial Hosting > luan
annotate src/luan/modules/http/LuanDomainHandler.java @ 1321:307e76ccd0d6
generalize separate logging
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 05 Feb 2019 22:36:55 -0700 |
parents | 5763597ca5c0 |
children | 55b8210b4ec0 |
rev | line source |
---|---|
1315 | 1 package luan.modules.http; |
2 | |
3 import luan.webserver.Request; | |
4 import luan.webserver.Response; | |
5 import luan.webserver.Handler; | |
6 import luan.webserver.handlers.DomainHandler; | |
7 import luan.LuanState; | |
8 import luan.LuanTable; | |
9 import luan.LuanCloner; | |
10 import luan.LuanException; | |
1321
307e76ccd0d6
generalize separate logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1315
diff
changeset
|
11 import luan.modules.logging.LuanLogger; |
1315 | 12 |
13 | |
14 public final class LuanDomainHandler implements Handler { | |
15 | |
16 private final LuanState luanInit; | |
17 | |
18 private final DomainHandler.Factory factory = new DomainHandler.Factory() { | |
19 public Handler newHandler(String domain) { | |
20 LuanCloner cloner = new LuanCloner(LuanCloner.Type.COMPLETE); | |
21 LuanState luan = (LuanState)cloner.clone(luanInit); | |
22 try { | |
1321
307e76ccd0d6
generalize separate logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1315
diff
changeset
|
23 LuanLogger.newLoggerRepository(luan); |
1315 | 24 LuanTable Http = (LuanTable)luan.require("luan:http/Http.luan"); |
25 Http.put( "domain", domain ); | |
26 } catch(LuanException e) { | |
27 throw new RuntimeException(e); | |
28 } | |
1321
307e76ccd0d6
generalize separate logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1315
diff
changeset
|
29 return new LuanHandler(luan); |
1315 | 30 } |
31 }; | |
32 | |
33 private final DomainHandler domainHandler = new DomainHandler(factory); | |
34 | |
35 public LuanDomainHandler(LuanState luanInit) { | |
36 LuanCloner cloner = new LuanCloner(LuanCloner.Type.COMPLETE); | |
37 this.luanInit = (LuanState)cloner.clone(luanInit); | |
38 } | |
39 | |
40 @Override public Response handle(Request request) { | |
41 return domainHandler.handle(request); | |
42 } | |
43 } |