Mercurial Hosting > luan
comparison 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 |
comparison
equal
deleted
inserted
replaced
85:b2551f00bc51 | 86:6db8f286fa6c |
---|---|
16 | 16 |
17 | 17 |
18 public final class HttpLib { | 18 public final class HttpLib { |
19 | 19 |
20 public static final String NAME = "http"; | 20 public static final String NAME = "http"; |
21 public static final String FN_NAME = "serve_http"; | 21 public static final String FN_NAME = "http.server"; |
22 | |
23 public static void load(LuanState luan) throws LuanException { | |
24 PackageLib.require(luan,NAME); | |
25 Object fn = luan.get(HttpLib.FN_NAME); | |
26 if( !(fn instanceof LuanFunction) ) | |
27 throw new LuanException( luan, LuanElement.JAVA, "function '"+HttpLib.FN_NAME+"' not defined" ); | |
28 } | |
22 | 29 |
23 public static void service(LuanState luan,HttpServletRequest request,HttpServletResponse response) | 30 public static void service(LuanState luan,HttpServletRequest request,HttpServletResponse response) |
24 throws LuanException, IOException | 31 throws LuanException, IOException |
25 { | 32 { |
26 LuanFunction fn = (LuanFunction)luan.global().get(FN_NAME); | 33 LuanFunction fn = (LuanFunction)luan.get(FN_NAME); |
27 ServletOutputStream sout = response.getOutputStream(); | 34 ServletOutputStream sout = response.getOutputStream(); |
28 luan.out = new PrintStream(sout); | 35 luan.out = new PrintStream(sout); |
29 | 36 |
30 LuanTable module = new LuanTable(); | 37 LuanTable module = (LuanTable)luan.loaded().get(NAME); |
31 luan.global().put(NAME,module); | |
32 | 38 |
33 LuanTable parameters = new LuanTable(); | 39 LuanTable parameters = new LuanTable(); |
34 LuanTable parameter_lists = new LuanTable(); | 40 LuanTable parameter_lists = new LuanTable(); |
35 @SuppressWarnings("unchecked") | 41 @SuppressWarnings("unchecked") |
36 Map<String,String[]> paramMap = request.getParameterMap(); | 42 Map<String,String[]> paramMap = request.getParameterMap(); |