changeset 1350:d8754a50adf1

better reset_luan
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 04 Mar 2019 09:41:50 -0700
parents 0cceff521abb
children 21b153b4bcc4
files src/luan/modules/http/LuanDomainHandler.java src/luan/modules/http/LuanHandler.java
diffstat 2 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/luan/modules/http/LuanDomainHandler.java	Wed Feb 27 12:30:46 2019 -0700
+++ b/src/luan/modules/http/LuanDomainHandler.java	Mon Mar 04 09:41:50 2019 -0700
@@ -7,6 +7,7 @@
 import luan.Luan;
 import luan.LuanTable;
 import luan.LuanCloner;
+import luan.LuanFunction;
 import luan.LuanException;
 import luan.modules.logging.Log4j;
 
@@ -30,13 +31,20 @@
 		Log4j.newLoggerRepository(luan);
 	}
 
-	protected Luan newLuan(String domain) {
+	protected Luan newLuan(final String domain) {
 		LuanCloner cloner = new LuanCloner(LuanCloner.Type.COMPLETE);
 		Luan luan = (Luan)cloner.clone(luanInit);
 		newLoggerRepository(luan);
+		LuanFunction reset_luan = new LuanFunction(false) {
+			@Override public Object call(Object[] args) {
+				domainHandler.removeHandler(domain);
+				return LuanFunction.NOTHING;
+			}
+		};
 		try {
 			LuanTable Http = (LuanTable)luan.require("luan:http/Http.luan");
 			Http.put( "domain", domain );
+			Http.put( "reset_luan", reset_luan );
 		} catch(LuanException e) {
 			throw new RuntimeException(e);
 		}
--- a/src/luan/modules/http/LuanHandler.java	Wed Feb 27 12:30:46 2019 -0700
+++ b/src/luan/modules/http/LuanHandler.java	Mon Mar 04 09:41:50 2019 -0700
@@ -56,7 +56,8 @@
 		this.logger = LuanLogger.getLogger(luanInit,LuanHandler.class.getName());
 		try {
 			LuanTable Http = (LuanTable)luanInit.require("luan:http/Http.luan");
-			Http.put( "reset_luan", new LuanJavaFunction(luanInit,resetLuanMethod,this) );
+			if( Http.get("reset_luan") == null )
+				Http.put( "reset_luan", new LuanJavaFunction(luanInit,resetLuanMethod,this) );
 			Http.put( "eval_in_root", new LuanJavaFunction(luanInit,evalInRootMethod,this) );
 			Http.put( "disable_luan", new LuanJavaFunction(luanInit,disableLuanMethod,this) );
 		} catch(LuanException e) {