Mercurial Hosting > luan
changeset 573:894f991baac5
remove LuanServlet
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 12 Jul 2015 23:04:47 -0600 |
parents | f1601a4ce1aa |
children | 6cc2f047019b |
files | http/src/luan/modules/http/LuanServlet.java |
diffstat | 1 files changed, 0 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
diff -r f1601a4ce1aa -r 894f991baac5 http/src/luan/modules/http/LuanServlet.java --- a/http/src/luan/modules/http/LuanServlet.java Sun Jul 12 21:34:23 2015 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -package luan.modules.http; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import luan.LuanState; -import luan.LuanException; - - -public class LuanServlet extends HttpServlet { - protected final String uriPrefix; - protected final LuanState luan; - - public LuanServlet(String uriPrefix,LuanState luan) { - this.uriPrefix = uriPrefix; - this.luan = luan; - } - - public LuanServlet(String uriPrefix) { - this(uriPrefix,LuanState.newInstance()); - } - - @Override protected void service(HttpServletRequest request,HttpServletResponse response) - throws IOException - { - String path = request.getRequestURI(); - service(request,response,path); - } - - public void service(HttpServletRequest request,HttpServletResponse response,String path) - throws IOException - { - if( !path.endsWith(".luan") ) - throw new RuntimeException("'"+path+"' doesn't end with '.luan'"); - String uri = uriPrefix + path.substring(0,path.length()-5); - try { - if( !HttpServicer.service(luan,request,response,uri) ) - response.sendError(HttpServletResponse.SC_NOT_FOUND); - } catch(LuanException e) { - throw new RuntimeException(e); - } - } - -}