Search in sources :

Example 16 with ConfigurableServletWebServerFactory

use of org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory in project jhipster-sample-app-dto by jhipster.

the class WebConfigurer method setMimeMappings.

private void setMimeMappings(WebServerFactory server) {
    if (server instanceof ConfigurableServletWebServerFactory) {
        MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
        // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711
        mappings.add("html", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase());
        // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64
        mappings.add("json", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase());
        ConfigurableServletWebServerFactory servletWebServer = (ConfigurableServletWebServerFactory) server;
        servletWebServer.setMimeMappings(mappings);
    }
}
Also used : ConfigurableServletWebServerFactory(org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory)

Example 17 with ConfigurableServletWebServerFactory

use of org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory in project jhipster-sample-app-oauth2 by jhipster.

the class WebConfigurer method setMimeMappings.

private void setMimeMappings(WebServerFactory server) {
    if (server instanceof ConfigurableServletWebServerFactory) {
        MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
        // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711
        mappings.add("html", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase());
        // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64
        mappings.add("json", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase());
        ConfigurableServletWebServerFactory servletWebServer = (ConfigurableServletWebServerFactory) server;
        servletWebServer.setMimeMappings(mappings);
    }
}
Also used : ConfigurableServletWebServerFactory(org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory)

Example 18 with ConfigurableServletWebServerFactory

use of org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory in project jhipster-sample-app-oauth2 by jhipster.

the class WebConfigurer method setLocationForStaticAssets.

private void setLocationForStaticAssets(WebServerFactory server) {
    if (server instanceof ConfigurableServletWebServerFactory) {
        ConfigurableServletWebServerFactory servletWebServer = (ConfigurableServletWebServerFactory) server;
        File root;
        String prefixPath = resolvePathPrefix();
        root = new File(prefixPath + "target/www/");
        if (root.exists() && root.isDirectory()) {
            servletWebServer.setDocumentRoot(root);
        }
    }
}
Also used : ConfigurableServletWebServerFactory(org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory) File(java.io.File)

Example 19 with ConfigurableServletWebServerFactory

use of org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory in project jhipster-sample-app-websocket by jhipster.

the class WebConfigurer method setLocationForStaticAssets.

private void setLocationForStaticAssets(WebServerFactory server) {
    if (server instanceof ConfigurableServletWebServerFactory) {
        ConfigurableServletWebServerFactory servletWebServer = (ConfigurableServletWebServerFactory) server;
        File root;
        String prefixPath = resolvePathPrefix();
        root = new File(prefixPath + "target/www/");
        if (root.exists() && root.isDirectory()) {
            servletWebServer.setDocumentRoot(root);
        }
    }
}
Also used : ConfigurableServletWebServerFactory(org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory) File(java.io.File)

Example 20 with ConfigurableServletWebServerFactory

use of org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory in project jhipster-sample-app-websocket by jhipster.

the class WebConfigurer method setMimeMappings.

private void setMimeMappings(WebServerFactory server) {
    if (server instanceof ConfigurableServletWebServerFactory) {
        MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
        // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711
        mappings.add("html", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase());
        // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64
        mappings.add("json", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase());
        ConfigurableServletWebServerFactory servletWebServer = (ConfigurableServletWebServerFactory) server;
        servletWebServer.setMimeMappings(mappings);
    }
}
Also used : ConfigurableServletWebServerFactory(org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory)

Aggregations

ConfigurableServletWebServerFactory (org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory)32 Test (org.junit.jupiter.api.Test)10 File (java.io.File)9 HashMap (java.util.HashMap)5 Test (org.junit.Test)5 Session (org.springframework.boot.web.servlet.server.Session)2 ServletContext (javax.servlet.ServletContext)1 SessionCookieConfig (javax.servlet.SessionCookieConfig)1 KeycloakAuthenticatorValve (org.keycloak.adapters.tomcat.KeycloakAuthenticatorValve)1 JettyServletWebServerFactory (org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory)1 TomcatServletWebServerFactory (org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory)1 UndertowServletWebServerFactory (org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory)1 MimeMappings (org.springframework.boot.web.server.MimeMappings)1 Shutdown (org.springframework.boot.web.server.Shutdown)1 Ssl (org.springframework.boot.web.server.Ssl)1 WebServerFactoryCustomizer (org.springframework.boot.web.server.WebServerFactoryCustomizer)1 Jsp (org.springframework.boot.web.servlet.server.Jsp)1 Cookie (org.springframework.boot.web.servlet.server.Session.Cookie)1 Bean (org.springframework.context.annotation.Bean)1