Mercurial Hosting > luan
annotate web/src/luan/modules/web/LuanServlet.java @ 400:8f1be9704726
change LuanState.newStandard() to newInstance() which doesn't preload anything
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 28 Apr 2015 13:12:17 -0600 |
parents | 199eb7f1b828 |
children | f86bf532f87c |
rev | line source |
---|---|
399 | 1 package luan.modules.web; |
2 | |
3 import java.io.IOException; | |
4 import javax.servlet.ServletException; | |
5 import javax.servlet.http.HttpServlet; | |
6 import javax.servlet.http.HttpServletRequest; | |
7 import javax.servlet.http.HttpServletResponse; | |
8 import luan.LuanState; | |
9 import luan.LuanException; | |
10 | |
11 | |
12 public class LuanServlet extends HttpServlet { | |
13 protected final String uriPrefix; | |
14 protected final LuanState luan; | |
15 | |
16 public LuanServlet(String uriPrefix,LuanState luan) { | |
17 this.uriPrefix = uriPrefix; | |
18 this.luan = luan; | |
19 } | |
20 | |
21 public LuanServlet(String uriPrefix) { | |
400
8f1be9704726
change LuanState.newStandard() to newInstance() which doesn't preload anything
Franklin Schmidt <fschmidt@gmail.com>
parents:
399
diff
changeset
|
22 this(uriPrefix,LuanState.newInstance()); |
399 | 23 } |
24 | |
25 protected void service(HttpServletRequest request,HttpServletResponse response) | |
26 throws IOException | |
27 { | |
28 String path = request.getRequestURI(); | |
29 if( !path.endsWith(".luan") ) | |
30 throw new RuntimeException("'"+path+"' doesn't end with '.luan'"); | |
31 String uri = uriPrefix + path.substring(0,path.length()-5); | |
32 //System.out.println("qqqqqqqqqqqqqqqqqqq "+uri); | |
33 try { | |
34 if( !HttpServicer.service(luan,request,response,uri) ) | |
35 response.sendError(HttpServletResponse.SC_NOT_FOUND); | |
36 } catch(LuanException e) { | |
37 throw new RuntimeException(e); | |
38 } | |
39 } | |
40 | |
41 } |