Mercurial Hosting > luan
changeset 313:1f6d828986b9
replace Http.request.servlet_path with Http.request.path;
rename Http.request.current_url to Http.request.url;
Web_server now loads welcome_file in init() for initialization;
fix cmd_line -e;
fix install for luan args;
git-svn-id: https://luan-java.googlecode.com/svn/trunk@314 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Thu, 25 Dec 2014 06:14:59 +0000 |
parents | d34be4588556 |
children | 7c4f52262213 |
files | core/src/luan/cmd_line.luan scripts/install.sh web/src/luan/modules/web/HttpServicer.java web/src/luan/modules/web/Web_server.luan |
diffstat | 4 files changed, 18 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/core/src/luan/cmd_line.luan Wed Dec 24 11:15:27 2014 +0000 +++ b/core/src/luan/cmd_line.luan Thu Dec 25 06:14:59 2014 +0000 @@ -5,7 +5,7 @@ local standalone_usage = [=[ -usage: java luan.CmdLine [options] [script [args]] +usage: java luan.Luan [options] [script [args]] Available options are: -e stat execute string 'stat' -i enter interactive mode after executing 'script' @@ -38,12 +38,12 @@ showVersion = true elseif arg == "-e" then i = i + 1 - if i == #args then + if i > #args then standalone_error "'-e' needs argument" return end local cmd = args[i] - local stat = load(cmd,"(command line)",true,true) + local stat = load(cmd,"(command line)",{},true) local result = Table.pack( stat() ) if result.n > 0 then print( Table.unpack(result,1,result.n) )
--- a/scripts/install.sh Wed Dec 24 11:15:27 2014 +0000 +++ b/scripts/install.sh Thu Dec 25 06:14:59 2014 +0000 @@ -3,7 +3,7 @@ cat >/usr/local/bin/luan <<End for i in `pwd`/jars/* ; do CLASSPATH=\$CLASSPATH:\$i ; done -java -classpath \$CLASSPATH luan.Luan \$* +java -classpath \$CLASSPATH luan.Luan "\$@" End chmod +x /usr/local/bin/luan
--- a/web/src/luan/modules/web/HttpServicer.java Wed Dec 24 11:15:27 2014 +0000 +++ b/web/src/luan/modules/web/HttpServicer.java Thu Dec 25 06:14:59 2014 +0000 @@ -111,7 +111,7 @@ } @Override Iterator<String> names() { - return new EnumerationIterator(request.getParameterNames()); + return new EnumerationIterator<String>(request.getParameterNames()); } @Override protected String type() { @@ -127,7 +127,7 @@ } @Override Iterator<String> names() { - return new EnumerationIterator(request.getHeaderNames()); + return new EnumerationIterator<String>(request.getHeaderNames()); } @Override protected String type() { @@ -138,14 +138,19 @@ tbl.put( "method", new LuanProperty() { public Object get() { return request.getMethod(); } } ); +/* tbl.put( "servlet_path", new LuanProperty() { public Object get() { return request.getServletPath(); } } ); +*/ + tbl.put( "path", new LuanProperty() { public Object get() { + return request.getRequestURI(); + } } ); tbl.put( "server_name", new LuanProperty() { public Object get() { return request.getServerName(); } } ); - tbl.put( "current_url", new LuanProperty() { public Object get() { - return getCurrentURL(request); + tbl.put( "url", new LuanProperty() { public Object get() { + return getURL(request); } } ); tbl.put( "query_string", new LuanProperty() { public Object get() { return getQueryString(request); @@ -257,7 +262,7 @@ } @Override Iterator<String> names() { - return new EnumerationIterator(request.getSession().getAttributeNames()); + return new EnumerationIterator<String>(request.getSession().getAttributeNames()); } @Override public void put(Object key,Object val) { @@ -352,11 +357,11 @@ return queryBuf.toString(); } - public static String getCurrentURL(HttpServletRequest request) { - return getCurrentURL(request,0); + public static String getURL(HttpServletRequest request) { + return getURL(request,0); } - public static String getCurrentURL(HttpServletRequest request,int maxValueLen) { + public static String getURL(HttpServletRequest request,int maxValueLen) { // StringBuffer buf = HttpUtils.getRequestURL(request); StringBuffer buf = request.getRequestURL(); String qStr = getQueryString(request,maxValueLen);
--- a/web/src/luan/modules/web/Web_server.luan Wed Dec 24 11:15:27 2014 +0000 +++ b/web/src/luan/modules/web/Web_server.luan Thu Dec 25 06:14:59 2014 +0000 @@ -84,6 +84,7 @@ luan_handler.setWelcomeFile(welcome_file) server = Server.new(port) server.setHandler(hc) + Package.load("site:/"..welcome_file) end function start()