changeset 183:ed19d14360fa

add LuanHandler.setWelcomeFile() git-svn-id: https://luan-java.googlecode.com/svn/trunk@184 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Wed, 25 Jun 2014 02:08:12 +0000
parents e6d6596a8bcc
children 69f1e79a9eb0
files dist/luan-core-trunk.jar dist/luan-web-trunk.jar web/src/luan/modules/web/LuanHandler.java web/src/luan/modules/web/Web_server.luan
diffstat 4 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
diff -r e6d6596a8bcc -r ed19d14360fa dist/luan-core-trunk.jar
Binary file dist/luan-core-trunk.jar has changed
diff -r e6d6596a8bcc -r ed19d14360fa dist/luan-web-trunk.jar
Binary file dist/luan-web-trunk.jar has changed
diff -r e6d6596a8bcc -r ed19d14360fa web/src/luan/modules/web/LuanHandler.java
--- a/web/src/luan/modules/web/LuanHandler.java	Tue Jun 24 08:34:39 2014 +0000
+++ b/web/src/luan/modules/web/LuanHandler.java	Wed Jun 25 02:08:12 2014 +0000
@@ -13,6 +13,7 @@
 
 public class LuanHandler extends AbstractHandler {
 	private final LuanState luan;
+	private String welcomeFile = "index.html";
 
 	LuanHandler(LuanState luan) {
 		this.luan = luan;
@@ -21,6 +22,8 @@
 	public void handle(String target,Request baseRequest,HttpServletRequest request,HttpServletResponse response) 
 		throws IOException
 	{
+		if( target.endsWith("/") )
+			target += welcomeFile;
 		try {
 			if( !HttpLuan.service(luan,request,response,target) )
 				return;
@@ -31,4 +34,8 @@
 		}
 		baseRequest.setHandled(true);
 	}
+
+	public void setWelcomeFile(String welcomeFile) {
+		this.welcomeFile = welcomeFile;
+	}
 }
diff -r e6d6596a8bcc -r ed19d14360fa web/src/luan/modules/web/Web_server.luan
--- a/web/src/luan/modules/web/Web_server.luan	Tue Jun 24 08:34:39 2014 +0000
+++ b/web/src/luan/modules/web/Web_server.luan	Wed Jun 25 02:08:12 2014 +0000
@@ -16,6 +16,8 @@
 
 port = 8080
 
+welcome_file = "index.html"
+
 
 session_handler = SessionHandler.new()
 
@@ -57,6 +59,8 @@
 	dir = dir.gsub("/$","")  -- remove trailing '/' if any
 	Package.path = dir.."?.luan;java:luan/modules/?.luan"
 	resource_handler.setResourceBase(dir)
+	resource_handler.setWelcomeFiles {welcome_file}
+	luan_handler.setWelcomeFile(welcome_file)
 	local server = Server.new(port)
 	server.setHandler(hc);
 	server.start()