Mercurial Hosting > luan
view src/luan/modules/http/LuanDomainHandler.java @ 1347:643cf1c37723
move webserver to lib and bug fixes
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 25 Feb 2019 13:02:33 -0700 |
parents | 7483108154bb |
children | d8754a50adf1 |
line wrap: on
line source
package luan.modules.http; import luan.lib.webserver.Request; import luan.lib.webserver.Response; import luan.lib.webserver.Handler; import luan.lib.webserver.handlers.DomainHandler; import luan.Luan; import luan.LuanTable; import luan.LuanCloner; import luan.LuanException; import luan.modules.logging.Log4j; public class LuanDomainHandler implements Handler, DomainHandler.Factory { private final Luan luanInit; private final DomainHandler domainHandler = new DomainHandler(this); public LuanDomainHandler(Luan luanInit) { LuanCloner cloner = new LuanCloner(LuanCloner.Type.COMPLETE); this.luanInit = (Luan)cloner.clone(luanInit); } @Override public Handler newHandler(String domain) { Luan luan = newLuan(domain); return new LuanHandler(luan); } protected void newLoggerRepository(Luan luan) { Log4j.newLoggerRepository(luan); } protected Luan newLuan(String domain) { LuanCloner cloner = new LuanCloner(LuanCloner.Type.COMPLETE); Luan luan = (Luan)cloner.clone(luanInit); newLoggerRepository(luan); try { LuanTable Http = (LuanTable)luan.require("luan:http/Http.luan"); Http.put( "domain", domain ); } catch(LuanException e) { throw new RuntimeException(e); } return luan; } @Override public Response handle(Request request) { return domainHandler.handle(request); } }