changeset 182:e6d6596a8bcc

improve Web_server git-svn-id: https://luan-java.googlecode.com/svn/trunk@183 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Tue, 24 Jun 2014 08:34:39 +0000
parents 5d2cb8c1f844
children ed19d14360fa
files dist/luan-core-trunk.jar dist/luan-web-trunk.jar web/src/luan/modules/web/Web_server.luan
diffstat 3 files changed, 23 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
diff -r 5d2cb8c1f844 -r e6d6596a8bcc dist/luan-core-trunk.jar
Binary file dist/luan-core-trunk.jar has changed
diff -r 5d2cb8c1f844 -r e6d6596a8bcc dist/luan-web-trunk.jar
Binary file dist/luan-web-trunk.jar has changed
diff -r 5d2cb8c1f844 -r e6d6596a8bcc web/src/luan/modules/web/Web_server.luan
--- a/web/src/luan/modules/web/Web_server.luan	Tue Jun 24 07:16:53 2014 +0000
+++ b/web/src/luan/modules/web/Web_server.luan	Tue Jun 24 08:34:39 2014 +0000
@@ -7,6 +7,9 @@
 import "org.eclipse.jetty.server.handler.HandlerCollection"
 import "org.eclipse.jetty.server.handler.ResourceHandler"
 import "org.eclipse.jetty.server.handler.RequestLogHandler"
+import "org.eclipse.jetty.server.handler.ContextHandler"
+import "org.eclipse.jetty.server.handler.GzipHandler"
+import "org.eclipse.jetty.server.handler.HandlerWrapper"
 import "org.eclipse.jetty.server.session.SessionHandler"
 import "web/Http"
 
@@ -21,7 +24,25 @@
 resource_handler = ResourceHandler.new()
 
 handlers = HandlerList.new()
-handlers.setHandlers { session_handler, luan_handler, resource_handler, DefaultHandler.new(), log_handler }
+handlers.setHandlers { session_handler, luan_handler, resource_handler }
+
+function add_folder(context,dir)
+	local rh = ResourceHandler.new()
+	rh.setResourceBase(dir)
+	local ch = ContextHandler.new(context)
+	ch.setHandler(rh)
+	handlers.addHandler(ch)
+	return rh
+end
+
+handler_wrapper = HandlerWrapper.new()
+handler_wrapper.setHandler(handlers)
+
+function zip()
+	local h = GzipHandler.new()
+	h.setHandler(handler_wrapper.getHandler())
+	handler_wrapper.setHandler(h)
+end
 
 log = NCSARequestLog.new()
 log.setExtended(false)
@@ -29,7 +50,7 @@
 log_handler.setRequestLog(log)
 
 local hc = HandlerCollection.new()
-hc.setHandlers { handlers, log_handler }
+hc.setHandlers { handler_wrapper, DefaultHandler.new(), log_handler }
  
 
 function serve(dir)