Mercurial Hosting > luan
comparison web/src/luan/modules/web/HttpServicer.java @ 477:b8ddd55c9b11
delete LuanExitException
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 11 May 2015 14:36:33 -0600 |
parents | bf5e62a9090c |
children | 44caaa6a3d92 |
comparison
equal
deleted
inserted
replaced
476:cd22e4694ea3 | 477:b8ddd55c9b11 |
---|---|
29 import luan.LuanElement; | 29 import luan.LuanElement; |
30 import luan.LuanException; | 30 import luan.LuanException; |
31 import luan.LuanTable; | 31 import luan.LuanTable; |
32 import luan.LuanMeta; | 32 import luan.LuanMeta; |
33 import luan.LuanJavaFunction; | 33 import luan.LuanJavaFunction; |
34 import luan.LuanExitException; | |
35 import luan.LuanPropertyMeta; | 34 import luan.LuanPropertyMeta; |
36 import luan.DeepCloner; | 35 import luan.DeepCloner; |
37 import luan.modules.PackageLuan; | 36 import luan.modules.PackageLuan; |
38 import luan.modules.IoLuan; | 37 import luan.modules.IoLuan; |
39 import luan.modules.TableLuan; | 38 import luan.modules.TableLuan; |
87 */ | 86 */ |
88 } catch(NoSuchMethodException e) { | 87 } catch(NoSuchMethodException e) { |
89 throw new RuntimeException(e); | 88 throw new RuntimeException(e); |
90 } | 89 } |
91 | 90 |
92 try { | 91 luan.call(fn,"<http>"); |
93 luan.call(fn,"<http>"); | |
94 } catch(LuanExitException e) { | |
95 // System.out.println("caught LuanExitException"); | |
96 } | |
97 return true; | 92 return true; |
98 } | 93 } |
99 | 94 |
100 private static LuanFunction getService(LuanState luan,LuanTable tbl) | 95 private static LuanFunction getService(LuanState luan,LuanTable tbl) |
101 throws LuanException | 96 throws LuanException |
273 private LuanTable responseTable() throws NoSuchMethodException { | 268 private LuanTable responseTable() throws NoSuchMethodException { |
274 LuanTable tbl = LuanPropertyMeta.INSTANCE.newTable(); | 269 LuanTable tbl = LuanPropertyMeta.INSTANCE.newTable(); |
275 LuanTable getters = LuanPropertyMeta.INSTANCE.getters(tbl); | 270 LuanTable getters = LuanPropertyMeta.INSTANCE.getters(tbl); |
276 LuanTable setters = LuanPropertyMeta.INSTANCE.setters(tbl); | 271 LuanTable setters = LuanPropertyMeta.INSTANCE.setters(tbl); |
277 tbl.rawPut("java",response); | 272 tbl.rawPut("java",response); |
278 add( tbl, "send_redirect", String.class ); | 273 tbl.rawPut( "send_redirect", new LuanJavaFunction( |
279 add( tbl, "send_error", Integer.TYPE, String.class ); | 274 HttpServletResponse.class.getMethod( "sendRedirect", String.class ), response |
275 ) ); | |
276 tbl.rawPut( "send_error", new LuanJavaFunction( | |
277 HttpServletResponse.class.getMethod( "sendError", Integer.TYPE, String.class ), response | |
278 ) ); | |
280 LuanTable headers = new NameMeta() { | 279 LuanTable headers = new NameMeta() { |
281 | 280 |
282 @Override Object get(String name) { | 281 @Override Object get(String name) { |
283 return response.getHeader(name); | 282 return response.getHeader(name); |
284 } | 283 } |
389 return IoLuan.textWriter(response.getWriter()); | 388 return IoLuan.textWriter(response.getWriter()); |
390 } | 389 } |
391 | 390 |
392 public Object[] get_parameter_values(String name) { | 391 public Object[] get_parameter_values(String name) { |
393 return request.getParameterValues(name); | 392 return request.getParameterValues(name); |
394 } | |
395 | |
396 public void send_redirect(String redirectUrl) | |
397 throws IOException | |
398 { | |
399 response.sendRedirect(redirectUrl); | |
400 throw new LuanExitException(); | |
401 } | |
402 | |
403 public void send_error(int code,String text) | |
404 throws IOException | |
405 { | |
406 response.sendError(code, text); | |
407 throw new LuanExitException(); | |
408 } | 393 } |
409 | 394 |
410 public void set_cookie(String name,String value,boolean isPersistent, String domain) { | 395 public void set_cookie(String name,String value,boolean isPersistent, String domain) { |
411 setCookie(request,response,name,value,isPersistent,domain); | 396 setCookie(request,response,name,value,isPersistent,domain); |
412 } | 397 } |