Search in sources :

Example 1 with Http4K

use of org.nustaq.kontraktor.remoting.http.undertow.Http4K in project kontraktor by RuedigerMoeller.

the class BldFourK method build.

public BldFourK build() {
    Http4K http4K = Http4K.get();
    // fixme https
    http4K.getServer(getPort(), getHostName(), context);
    getItems().forEach(item -> {
        if (item instanceof HttpPublisher) {
            http4K.publish((HttpPublisher) item);
        } else if (item instanceof WebSocketPublisher) {
            http4K.publish((WebSocketPublisher) item);
        } else if (item instanceof BldDirRoot) {
            BldDirRoot dr = (BldDirRoot) item;
            if (getHttpCacheEnabled()) {
                CachedFileResourceManager resMan = new CachedFileResourceManager(getHttpCacheEnabled(), new File(dr.getDir()), 100);
                http4K.publishFileSystem(getHostName(), dr.getUrlPath(), getPort(), resMan);
            } else {
                http4K.publishFileSystem(getHostName(), dr.getUrlPath(), getPort(), new File(dr.getDir()));
            }
        } else if (item instanceof BldHttpHandler) {
            BldHttpHandler dr = (BldHttpHandler) item;
            http4K.publishHandler(getHostName(), dr.getUrlPath(), getPort(), dr.getHandler());
        } else if (item instanceof BldResPath) {
            BldResPath dr = (BldResPath) item;
            DynamicResourceManager drm = new DynamicResourceManager(!dr.isCacheAggregates(), dr.getUrlPath(), dr.isMinify(), dr.getBaseDir(), dr.getResourcePath());
            drm.cachedIndexDir(dr.getProductionBuildDir());
            HtmlImportShim shim = new HtmlImportShim(dr.getUrlPath());
            drm.setJSPostProcessors(dr.getProdModePostProcessors());
            shim.setJSPostProcessors(dr.getProdModePostProcessors());
            shim.minify(dr.isMinify()).inline(dr.isInline()).stripComments(dr.isStripComments());
            drm.setImportShim(shim);
            drm.setTranspilerMap(dr.getTranspilers());
            http4K.publishResourcePath(getHostName(), dr.getUrlPath(), getPort(), drm, dr.isCompress(), dr.getHandlerInterceptor());
        } else {
            System.out.println("unexpected item " + item);
        }
    });
    return this;
}
Also used : HttpPublisher(org.nustaq.kontraktor.remoting.http.undertow.HttpPublisher) WebSocketPublisher(org.nustaq.kontraktor.remoting.http.undertow.WebSocketPublisher) Http4K(org.nustaq.kontraktor.remoting.http.undertow.Http4K) File(java.io.File)

Aggregations

File (java.io.File)1 Http4K (org.nustaq.kontraktor.remoting.http.undertow.Http4K)1 HttpPublisher (org.nustaq.kontraktor.remoting.http.undertow.HttpPublisher)1 WebSocketPublisher (org.nustaq.kontraktor.remoting.http.undertow.WebSocketPublisher)1