Mercurial Hosting > luan
view src/luan/modules/http/LuanDomainHandler.java @ 1321:307e76ccd0d6
generalize separate logging
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 05 Feb 2019 22:36:55 -0700 |
parents | 5763597ca5c0 |
children | 55b8210b4ec0 |
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.LuanLogger; public final class LuanDomainHandler implements Handler { private final LuanState luanInit; private final DomainHandler.Factory factory = new DomainHandler.Factory() { public Handler newHandler(String domain) { LuanCloner cloner = new LuanCloner(LuanCloner.Type.COMPLETE); LuanState luan = (LuanState)cloner.clone(luanInit); try { LuanLogger.newLoggerRepository(luan); LuanTable Http = (LuanTable)luan.require("luan:http/Http.luan"); Http.put( "domain", domain ); } catch(LuanException e) { throw new RuntimeException(e); } return new LuanHandler(luan); } }; private final DomainHandler domainHandler = new DomainHandler(factory); public LuanDomainHandler(LuanState luanInit) { LuanCloner cloner = new LuanCloner(LuanCloner.Type.COMPLETE); this.luanInit = (LuanState)cloner.clone(luanInit); } @Override public Response handle(Request request) { return domainHandler.handle(request); } }