Mercurial Hosting > luan
view src/luan/modules/http/LuanDomainHandler.java @ 1332:11b7e11f9ed5
cleaner logging
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 12 Feb 2019 21:50:26 -0700 |
parents | 5a39b006acd1 |
children | 25746915a241 |
line wrap: on
line source
package luan.modules.http; import luan.webserver.Request; import luan.webserver.Response; import luan.webserver.Handler; import luan.webserver.handlers.DomainHandler; import luan.LuanState; import luan.LuanTable; import luan.LuanCloner; import luan.LuanException; import luan.modules.logging.Log4j; public class LuanDomainHandler implements Handler, DomainHandler.Factory { private final LuanState luanInit; private final DomainHandler domainHandler = new DomainHandler(this); public LuanDomainHandler(LuanState luanInit) { LuanCloner cloner = new LuanCloner(LuanCloner.Type.COMPLETE); this.luanInit = (LuanState)cloner.clone(luanInit); } @Override public Handler newHandler(String domain) { LuanState luan = newLuan(domain); return new LuanHandler(luan); } protected void newLoggerRepository(LuanState luan) throws LuanException { Log4j.newLoggerRepository(luan); } protected LuanState newLuan(String domain) { LuanCloner cloner = new LuanCloner(LuanCloner.Type.COMPLETE); LuanState luan = (LuanState)cloner.clone(luanInit); try { newLoggerRepository(luan); 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); } }