diff src/luan/modules/http/LuanHandler.java @ 1562:b89212fd04b5

remove table.luan
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 08 Nov 2020 16:50:59 -0700
parents 219f2b937f2b
children 8fbcc4747091
line wrap: on
line diff
--- a/src/luan/modules/http/LuanHandler.java	Thu Nov 05 20:24:09 2020 -0700
+++ b/src/luan/modules/http/LuanHandler.java	Sun Nov 08 16:50:59 2020 -0700
@@ -66,11 +66,11 @@
 		try {
 			Fns fns = new Fns(this);
 			LuanTable Http = (LuanTable)luanInit.require("luan:http/Http.luan");
-			if( Http.get("reset_luan") == null )
-				Http.put( "reset_luan", new LuanJavaFunction(luanInit,resetLuanMethod,fns) );
-			Http.put( "eval_in_root", new LuanJavaFunction(luanInit,evalInRootMethod,fns) );
-			Http.put( "disable_luan", new LuanJavaFunction(luanInit,disableLuanMethod,fns) );
-			Http.put( "dont_gc", new LuanJavaFunction(luanInit,dontGcMethod,fns) );
+			if( Http.get(luanInit,"reset_luan") == null )
+				Http.put( luanInit, "reset_luan", new LuanJavaFunction(luanInit,resetLuanMethod,fns) );
+			Http.put( luanInit, "eval_in_root", new LuanJavaFunction(luanInit,evalInRootMethod,fns) );
+			Http.put( luanInit, "disable_luan", new LuanJavaFunction(luanInit,disableLuanMethod,fns) );
+			Http.put( luanInit, "dont_gc", new LuanJavaFunction(luanInit,dontGcMethod,fns) );
 		} catch(LuanException e) {
 			throw new RuntimeException(e);
 		}
@@ -138,7 +138,7 @@
 		//logger.info("close "+domain+" "+(obj!=null));
 	}
 
-	public Object call_rpc(String fnName,Object... args) throws LuanException {
+	public Object call_rpc(Luan luan,String fnName,Object... args) throws LuanException {
 		rwLock.readLock().lock();
 		LuanLogger.startThreadLogging(currentLuan);
 		try {
@@ -146,8 +146,8 @@
 			synchronized(luanInit) {
 				enableLoad("luan:Rpc.luan");
 				LuanTable rpc = (LuanTable)currentLuan.require("luan:Rpc.luan");
-				LuanTable fns = (LuanTable)rpc.get("functions");
-				fn = (LuanFunction)fns.get(fnName);
+				LuanTable fns = (LuanTable)rpc.get(luan,"functions");
+				fn = (LuanFunction)fns.get(luan,fnName);
 				if( fn == null )
 					throw new LuanException( "function not found: " + fnName );
 				LuanCloner cloner = new LuanCloner(LuanCloner.Type.INCREMENTAL);
@@ -256,7 +256,7 @@
 			luan = (Luan)cloner.clone(currentLuan);
 		}
 		LuanTable module = (LuanTable)luan.require("luan:http/Http.luan");
-		return (Response)module.fn("handle_error").call( request, e.table(luan) );
+		return (Response)module.fn(luan,"handle_error").call( request, e.table(luan) );
 	}
 
 	private Response serviceLuan(Request request)
@@ -278,10 +278,10 @@
 			fn = (LuanFunction)cloner.get(mod);
 		}
 		LuanTable module = (LuanTable)luan.require("luan:http/Http.luan");
-		module.fn("new_request").call(request);
-		module.fn("new_response").call();
+		module.fn(luan,"new_request").call(request);
+		module.fn(luan,"new_response").call();
 		fn.call();
-		return (Response)module.fn("finish").call();
+		return (Response)module.fn(luan,"finish").call();
 	}
 
 	private Response serviceNotFound(Request request)
@@ -292,7 +292,7 @@
 		synchronized(luanInit) {
 			enableLoad("luan:http/Http.luan");
  			LuanTable module = (LuanTable)currentLuan.require("luan:http/Http.luan");
-			fn = module.fn("not_found_handler");
+			fn = module.fn(currentLuan,"not_found_handler");
 			if( fn == null )
 				return null;
 			LuanCloner cloner = new LuanCloner(LuanCloner.Type.INCREMENTAL);
@@ -300,13 +300,13 @@
 			fn = (LuanFunction)cloner.get(fn);
 		}
 		LuanTable module = (LuanTable)luan.require("luan:http/Http.luan");
-		module.fn("new_request").call(request);
-		module.fn("new_response").call();
+		module.fn(luan,"new_request").call(request);
+		module.fn(luan,"new_response").call();
 		Object obj = Luan.first(fn.call());
 		if( !(obj instanceof Boolean) )
 			throw new LuanException("not_found_handler must return boolean");
 		boolean handled = (Boolean)obj;
-		return handled ? (Response)module.fn("finish").call() : null;
+		return handled ? (Response)module.fn(luan,"finish").call() : null;
 	}
 
 	private void enableLoad(String... mods) throws LuanException {