Mercurial Hosting > luan
diff http/src/luan/modules/http/HttpServicer.java @ 505:7bc63886d4f2
web page modules now return a function
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 21 May 2015 01:45:49 -0600 |
parents | dbdf4b8193a8 |
children | 7d1afc73f835 |
line wrap: on
line diff
--- a/http/src/luan/modules/http/HttpServicer.java Thu May 21 01:09:35 2015 -0600 +++ b/http/src/luan/modules/http/HttpServicer.java Thu May 21 01:45:49 2015 -0600 @@ -52,9 +52,8 @@ Object mod = PackageLuan.load(luan,modName); if( mod==null ) return false; - if( !(mod instanceof LuanTable) ) - throw luan.exception( "module '"+modName+"' must return a table" ); - LuanTable tbl = (LuanTable)mod; + if( !(mod instanceof LuanFunction) ) + throw luan.exception( "module '"+modName+"' must return a function" ); if( Boolean.TRUE.equals(per_session_pages.rawGet(mod)) ) { HttpSession session = request.getSession(); LuanState sessionLuan = (LuanState)session.getValue("luan"); @@ -65,13 +64,11 @@ luan = (LuanState)cloner.deepClone(luan); session.putValue("luan",luan); } - tbl = (LuanTable)PackageLuan.require(luan,modName); - fn = getService(luan,tbl); + fn = (LuanFunction)PackageLuan.require(luan,modName); } else { - fn = getService(luan,tbl); DeepCloner cloner = new DeepCloner(); luan = (LuanState)cloner.deepClone(luan); - fn = (LuanFunction)cloner.get(fn); + fn = (LuanFunction)cloner.get(mod); } } @@ -164,17 +161,6 @@ return true; } - private static LuanFunction getService(LuanState luan,LuanTable tbl) - throws LuanException - { - Object respond = tbl.get(luan,"respond"); - if( respond == null ) - throw luan.exception( "function 'respond' is not defined" ); - if( !(respond instanceof LuanFunction) ) - throw luan.exception( "'respond' must be a function but is a " + Luan.type(respond) ); - return (LuanFunction)respond; - } - private static void setResponse(LuanTable module,HttpServletResponse response) throws LuanException { LuanTable responseTbl = (LuanTable)module.rawGet("response"); int status = Luan.asInteger(responseTbl.rawGet("status"));