Mercurial Hosting > luan
comparison src/luan/modules/http/LuanDomainHandler.java @ 1350:d8754a50adf1
better reset_luan
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 04 Mar 2019 09:41:50 -0700 |
parents | 643cf1c37723 |
children | 221eedb0f54e |
comparison
equal
deleted
inserted
replaced
1349:0cceff521abb | 1350:d8754a50adf1 |
---|---|
5 import luan.lib.webserver.Handler; | 5 import luan.lib.webserver.Handler; |
6 import luan.lib.webserver.handlers.DomainHandler; | 6 import luan.lib.webserver.handlers.DomainHandler; |
7 import luan.Luan; | 7 import luan.Luan; |
8 import luan.LuanTable; | 8 import luan.LuanTable; |
9 import luan.LuanCloner; | 9 import luan.LuanCloner; |
10 import luan.LuanFunction; | |
10 import luan.LuanException; | 11 import luan.LuanException; |
11 import luan.modules.logging.Log4j; | 12 import luan.modules.logging.Log4j; |
12 | 13 |
13 | 14 |
14 public class LuanDomainHandler implements Handler, DomainHandler.Factory { | 15 public class LuanDomainHandler implements Handler, DomainHandler.Factory { |
28 | 29 |
29 protected void newLoggerRepository(Luan luan) { | 30 protected void newLoggerRepository(Luan luan) { |
30 Log4j.newLoggerRepository(luan); | 31 Log4j.newLoggerRepository(luan); |
31 } | 32 } |
32 | 33 |
33 protected Luan newLuan(String domain) { | 34 protected Luan newLuan(final String domain) { |
34 LuanCloner cloner = new LuanCloner(LuanCloner.Type.COMPLETE); | 35 LuanCloner cloner = new LuanCloner(LuanCloner.Type.COMPLETE); |
35 Luan luan = (Luan)cloner.clone(luanInit); | 36 Luan luan = (Luan)cloner.clone(luanInit); |
36 newLoggerRepository(luan); | 37 newLoggerRepository(luan); |
38 LuanFunction reset_luan = new LuanFunction(false) { | |
39 @Override public Object call(Object[] args) { | |
40 domainHandler.removeHandler(domain); | |
41 return LuanFunction.NOTHING; | |
42 } | |
43 }; | |
37 try { | 44 try { |
38 LuanTable Http = (LuanTable)luan.require("luan:http/Http.luan"); | 45 LuanTable Http = (LuanTable)luan.require("luan:http/Http.luan"); |
39 Http.put( "domain", domain ); | 46 Http.put( "domain", domain ); |
47 Http.put( "reset_luan", reset_luan ); | |
40 } catch(LuanException e) { | 48 } catch(LuanException e) { |
41 throw new RuntimeException(e); | 49 throw new RuntimeException(e); |
42 } | 50 } |
43 return luan; | 51 return luan; |
44 } | 52 } |