Search in sources :

Example 1 with StaticContentSupport

use of io.helidon.webserver.staticcontent.StaticContentSupport in project helidon by oracle.

the class ServerCdiExtension method registerClasspathStaticContent.

private void registerClasspathStaticContent(Config config) {
    Config context = config.get("context");
    StaticContentSupport.ClassPathBuilder cpBuilder = StaticContentSupport.builder(config.get("location").asString().get());
    cpBuilder.welcomeFileName(config.get("welcome").asString().orElse("index.html"));
    config.get("tmp-dir").as(Path.class).ifPresent(cpBuilder::tmpDir);
    StaticContentSupport staticContent = cpBuilder.build();
    if (context.exists()) {
        routingBuilder.register(context.asString().get(), staticContent);
    } else {
        routingBuilder.register(staticContent);
    }
    STARTUP_LOGGER.finest("Static classpath");
}
Also used : Path(java.nio.file.Path) StaticContentSupport(io.helidon.webserver.staticcontent.StaticContentSupport) Config(io.helidon.config.Config)

Example 2 with StaticContentSupport

use of io.helidon.webserver.staticcontent.StaticContentSupport in project helidon by oracle.

the class ServerCdiExtension method registerPathStaticContent.

private void registerPathStaticContent(Config config) {
    Config context = config.get("context");
    StaticContentSupport.FileSystemBuilder pBuilder = StaticContentSupport.builder(config.get("location").as(Path.class).get());
    config.get("welcome").asString().ifPresent(pBuilder::welcomeFileName);
    StaticContentSupport staticContent = pBuilder.build();
    if (context.exists()) {
        routingBuilder.register(context.asString().get(), staticContent);
    } else {
        routingBuilder.register(staticContent);
    }
    STARTUP_LOGGER.finest("Static path");
}
Also used : StaticContentSupport(io.helidon.webserver.staticcontent.StaticContentSupport) Config(io.helidon.config.Config)

Example 3 with StaticContentSupport

use of io.helidon.webserver.staticcontent.StaticContentSupport in project helidon by oracle.

the class Gh2631 method routing.

private static Routing routing() {
    StaticContentSupport classpath = StaticContentSupport.builder("web").welcomeFileName("index.txt").build();
    StaticContentSupport file = StaticContentSupport.builder(Paths.get("src/main/resources/web")).welcomeFileName("index.txt").build();
    return Routing.builder().register("/simple", classpath).register("/fallback", classpath).register("/fallback", StaticContentSupport.builder("fallback").pathMapper(path -> "index.txt").build()).register("/simpleFile", file).register("/fallbackFile", file).register("/fallbackFile", StaticContentSupport.builder(Paths.get("src/main/resources/fallback")).pathMapper(path -> "index.txt").build()).build();
}
Also used : TimeUnit(java.util.concurrent.TimeUnit) StaticContentSupport(io.helidon.webserver.staticcontent.StaticContentSupport) Paths(java.nio.file.Paths) WebServer(io.helidon.webserver.WebServer) Routing(io.helidon.webserver.Routing) StaticContentSupport(io.helidon.webserver.staticcontent.StaticContentSupport)

Aggregations

StaticContentSupport (io.helidon.webserver.staticcontent.StaticContentSupport)3 Config (io.helidon.config.Config)2 Routing (io.helidon.webserver.Routing)1 WebServer (io.helidon.webserver.WebServer)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 TimeUnit (java.util.concurrent.TimeUnit)1