Mercurial Hosting > luan
view src/luan/modules/http/LuanDomainHandler.java @ 1333:25746915a241
merge Luan and LuanState
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 12 Feb 2019 22:33:40 -0700 |
parents | 11b7e11f9ed5 |
children | 7483108154bb |
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.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) throws LuanException { Log4j.newLoggerRepository(luan); } protected Luan newLuan(String domain) { LuanCloner cloner = new LuanCloner(LuanCloner.Type.COMPLETE); Luan luan = (Luan)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); } }