Mercurial Hosting > luan
diff src/luan/lib/HttpLib.java @ 86:6db8f286fa6c
_ENV is per module, not global
git-svn-id: https://luan-java.googlecode.com/svn/trunk@87 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Wed, 27 Feb 2013 08:03:51 +0000 |
parents | 4bf3d0c0b6b9 |
children | 6ca02b188dba |
line wrap: on
line diff
--- a/src/luan/lib/HttpLib.java Mon Feb 25 03:53:54 2013 +0000 +++ b/src/luan/lib/HttpLib.java Wed Feb 27 08:03:51 2013 +0000 @@ -18,17 +18,23 @@ public final class HttpLib { public static final String NAME = "http"; - public static final String FN_NAME = "serve_http"; + public static final String FN_NAME = "http.server"; + + public static void load(LuanState luan) throws LuanException { + PackageLib.require(luan,NAME); + Object fn = luan.get(HttpLib.FN_NAME); + if( !(fn instanceof LuanFunction) ) + throw new LuanException( luan, LuanElement.JAVA, "function '"+HttpLib.FN_NAME+"' not defined" ); + } public static void service(LuanState luan,HttpServletRequest request,HttpServletResponse response) throws LuanException, IOException { - LuanFunction fn = (LuanFunction)luan.global().get(FN_NAME); + LuanFunction fn = (LuanFunction)luan.get(FN_NAME); ServletOutputStream sout = response.getOutputStream(); luan.out = new PrintStream(sout); - LuanTable module = new LuanTable(); - luan.global().put(NAME,module); + LuanTable module = (LuanTable)luan.loaded().get(NAME); LuanTable parameters = new LuanTable(); LuanTable parameter_lists = new LuanTable();