Search in sources :

Example 1 with WebServer

use of io.helidon.webserver.WebServer in project visuale by Cantara.

the class Main method startServer.

public WebServer startServer(int port, String contextPath) {
    Routing routing = Routing.builder().register(contextPath, healthResource).register(contextPath, statusResource).register(contextPath + "/favicon.ico", StaticContentSupport.builder("/nuxt-spa/dist/favicon.ico").build()).register(contextPath + "/nuxt-spa", StaticContentSupport.builder("/nuxt-spa").build()).register(contextPath + "/_nuxt", StaticContentSupport.builder("/nuxt-spa/dist/_nuxt").build()).register(contextPath + "/", StaticContentSupport.builder("/nuxt-spa/dist").welcomeFileName("index.html").build()).build();
    WebServer ws = WebServer.builder().port(port).addMediaSupport(JacksonSupport.create()).routing(routing).build();
    // start the server
    // Server server = startServer();
    ws.start().thenApply(webServer -> {
        if (accessToken == null || accessToken.length() < 1) {
            String endpoint = "http://localhost:" + webServer.port() + contextPath;
            System.out.println("- Visit Dashboard at: " + endpoint + "/?ui_extension=groupByTag&servicetype=true");
            System.out.println(" - Health checks available on: " + endpoint + "/health");
            System.out.println(" - Environment status available on:  " + endpoint + "/status/");
        } else {
            String endpoint = "http://localhost:" + webServer.port() + contextPath;
            System.out.println(" Visit Dashboard at: " + endpoint + "/?accessToken=" + accessToken + "&ui_extension=groupByTag&servicetype=true");
            System.out.println(" - Health checks available on: " + endpoint + "/health");
            System.out.println(" - Environment status available on:  " + endpoint + "/status/?accessToken=" + accessToken);
        }
        return null;
    });
    return ws;
}
Also used : WebServer(io.helidon.webserver.WebServer) Routing(io.helidon.webserver.Routing)

Example 2 with WebServer

use of io.helidon.webserver.WebServer in project metro-jax-ws by eclipse-ee4j.

the class Main method startServer.

static WebServer startServer() {
    setupLogging();
    // By default this will pick up application.yaml from the classpath
    Config config = buildConfig();
    // Get webserver config from the "server" section of application.yaml
    WebServer server = WebServer.builder().config(config.get("server")).routing(buildRouting(config)).build();
    // Try to start the server. If successful, print some info and arrange to
    // print a message at shutdown. If unsuccessful, print the exception.
    server.start().thenAccept(ws -> {
        System.out.println("WEB server is up! http://localhost:" + ws.port());
        ws.whenShutdown().thenRun(() -> System.out.println("WEB server is DOWN. Good bye!"));
    }).exceptionally(t -> {
        System.err.println("Startup failed: " + t.getMessage());
        t.printStackTrace(System.err);
        return null;
    });
    // Server threads are not daemon. No need to block. Just react.
    return server;
}
Also used : Config(io.helidon.config.Config) LogManager(java.util.logging.LogManager) WebServer(io.helidon.webserver.WebServer) MetroSupport(org.eclipse.metro.helidon.MetroSupport) IOException(java.io.IOException) ConfigSources(io.helidon.config.ConfigSources) Routing(io.helidon.webserver.Routing) InputStream(java.io.InputStream) WebServer(io.helidon.webserver.WebServer) Config(io.helidon.config.Config)

Example 3 with WebServer

use of io.helidon.webserver.WebServer in project metro-jax-ws by eclipse-ee4j.

the class Main method startServer.

static WebServer startServer() {
    setupLogging();
    // By default this will pick up application.yaml from the classpath
    Config config = buildConfig();
    // Get webserver config from the "server" section of application.yaml
    WebServer server = WebServer.builder().config(config.get("server")).routing(buildRouting(config)).build();
    // Try to start the server. If successful, print some info and arrange to
    // print a message at shutdown. If unsuccessful, print the exception.
    server.start().thenAccept(ws -> {
        System.out.println("WEB server is up! http://localhost:" + ws.port());
        ws.whenShutdown().thenRun(() -> System.out.println("WEB server is DOWN. Good bye!"));
    }).exceptionally(t -> {
        System.err.println("Startup failed: " + t.getMessage());
        t.printStackTrace(System.err);
        return null;
    });
    // Server threads are not daemon. No need to block. Just react.
    return server;
}
Also used : Config(io.helidon.config.Config) LogManager(java.util.logging.LogManager) WebServer(io.helidon.webserver.WebServer) MetroSupport(org.eclipse.metro.helidon.MetroSupport) IOException(java.io.IOException) ConfigSources(io.helidon.config.ConfigSources) Routing(io.helidon.webserver.Routing) InputStream(java.io.InputStream) WebServer(io.helidon.webserver.WebServer) Config(io.helidon.config.Config)

Example 4 with WebServer

use of io.helidon.webserver.WebServer in project metro-jax-ws by eclipse-ee4j.

the class Main method startServer.

static WebServer startServer() {
    setupLogging();
    // By default this will pick up application.yaml from the classpath
    Config config = buildConfig();
    // Get webserver config from the "server" section of application.yaml
    WebServer server = WebServer.builder().config(config.get("server")).routing(buildRouting(config)).build();
    // Try to start the server. If successful, print some info and arrange to
    // print a message at shutdown. If unsuccessful, print the exception.
    server.start().thenAccept(ws -> {
        System.out.println("WEB server is up! http://localhost:" + ws.port());
        ws.whenShutdown().thenRun(() -> System.out.println("WEB server is DOWN. Good bye!"));
    }).exceptionally(t -> {
        System.err.println("Startup failed: " + t.getMessage());
        t.printStackTrace(System.err);
        return null;
    });
    // Server threads are not daemon. No need to block. Just react.
    return server;
}
Also used : Config(io.helidon.config.Config) LogManager(java.util.logging.LogManager) WebServer(io.helidon.webserver.WebServer) MetroSupport(org.eclipse.metro.helidon.MetroSupport) IOException(java.io.IOException) ConfigSources(io.helidon.config.ConfigSources) Routing(io.helidon.webserver.Routing) InputStream(java.io.InputStream) WebServer(io.helidon.webserver.WebServer) Config(io.helidon.config.Config)

Example 5 with WebServer

use of io.helidon.webserver.WebServer in project metro-jax-ws by eclipse-ee4j.

the class Main method startServer.

static WebServer startServer() {
    setupLogging();
    // By default this will pick up application.yaml from the classpath
    Config config = buildConfig();
    // Get webserver config from the "server" section of application.yaml
    WebServer server = WebServer.builder().config(config.get("server")).routing(buildRouting(config)).build();
    // Try to start the server. If successful, print some info and arrange to
    // print a message at shutdown. If unsuccessful, print the exception.
    server.start().thenAccept(ws -> {
        System.out.println("WEB server is up! http://localhost:" + ws.port());
        ws.whenShutdown().thenRun(() -> System.out.println("WEB server is DOWN. Good bye!"));
    }).exceptionally(t -> {
        System.err.println("Startup failed: " + t.getMessage());
        t.printStackTrace(System.err);
        return null;
    });
    // Server threads are not daemon. No need to block. Just react.
    return server;
}
Also used : Config(io.helidon.config.Config) LogManager(java.util.logging.LogManager) WebServer(io.helidon.webserver.WebServer) MetroSupport(org.eclipse.metro.helidon.MetroSupport) IOException(java.io.IOException) ConfigSources(io.helidon.config.ConfigSources) Routing(io.helidon.webserver.Routing) RestService(org.eclipse.metro.helidon.example.client.RestService) InputStream(java.io.InputStream) WebServer(io.helidon.webserver.WebServer) Config(io.helidon.config.Config)

Aggregations

WebServer (io.helidon.webserver.WebServer)88 Config (io.helidon.config.Config)49 Routing (io.helidon.webserver.Routing)48 LogConfig (io.helidon.common.LogConfig)34 Single (io.helidon.common.reactive.Single)17 JsonpSupport (io.helidon.media.jsonp.JsonpSupport)16 MetricsSupport (io.helidon.metrics.MetricsSupport)16 HealthSupport (io.helidon.health.HealthSupport)15 HealthChecks (io.helidon.health.checks.HealthChecks)13 ConfigSources (io.helidon.config.ConfigSources)10 TimeUnit (java.util.concurrent.TimeUnit)10 WebClient (io.helidon.webclient.WebClient)9 WebClientResponse (io.helidon.webclient.WebClientResponse)9 CountDownLatch (java.util.concurrent.CountDownLatch)9 Test (org.junit.jupiter.api.Test)9 Http (io.helidon.common.http.Http)8 MediaType (io.helidon.common.http.MediaType)8 IOException (java.io.IOException)8 SecurityContext (io.helidon.security.SecurityContext)7 StaticContentSupport (io.helidon.webserver.staticcontent.StaticContentSupport)7