diff src/luan/modules/http/HttpServicer.java @ 1265:3f4644246e39

LuanHandler cleanup and add Server.serve_for_proxy
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 25 Sep 2018 19:51:34 -0600
parents 382c444a6c77
children 9fa8b8389578
line wrap: on
line diff
--- a/src/luan/modules/http/HttpServicer.java	Tue Sep 25 17:03:57 2018 -0600
+++ b/src/luan/modules/http/HttpServicer.java	Tue Sep 25 19:51:34 2018 -0600
@@ -4,7 +4,6 @@
 import org.slf4j.LoggerFactory;
 import luan.webserver.Request;
 import luan.webserver.Response;
-import luan.webserver.Status;
 import luan.LuanState;
 import luan.LuanFunction;
 import luan.LuanException;
@@ -16,7 +15,9 @@
 public final class HttpServicer {
 	private static final Logger logger = LoggerFactory.getLogger(HttpServicer.class);
 
-	public static Response service(LuanState luan,Request request,String modName) {
+	public static Response service(LuanState luan,Request request,String modName)
+		throws LuanException
+	{
 		try {
 			return serviceLuan(luan,request,modName);
 		} catch(LuanException e) {
@@ -24,25 +25,17 @@
 		}
 	}
 
-	private static Response handleError(LuanState luan,Request request,LuanException e) {
+	private static Response handleError(LuanState luan,Request request,LuanException e)
+		throws LuanException
+	{
 //e.printStackTrace();
-/*
-		String err = e.getLuanStackTraceString();
-		logger.error(err+"\n"+request.rawHead.trim()+"\n");
-		String msg = "Internel Server Error\n\n" + err;
-		return Response.errorResponse( Status.INTERNAL_SERVER_ERROR, msg );
-*/
 		synchronized(luan) {
 			LuanCloner cloner = new LuanCloner(LuanCloner.Type.INCREMENTAL);
 			luan = (LuanState)cloner.clone(luan);
 		}
-		try {
-			LuanTable module = (LuanTable)PackageLuan.require(luan,"luan:http/Http.luan");
-			LuanFunction fn = (LuanFunction)module.rawGet("handle_error");
-			return (Response)fn.call( luan, new Object[]{request,e.table()} );
-		} catch(LuanException e2) {
-			throw new RuntimeException(e2);
-		}
+		LuanTable module = (LuanTable)PackageLuan.require(luan,"luan:http/Http.luan");
+		LuanFunction fn = (LuanFunction)module.rawGet("handle_error");
+		return (Response)fn.call( luan, new Object[]{request,e.table()} );
 	}
 
 	private static Response serviceLuan(LuanState luan,Request request,String modName)