Java Code Examples for org.springframework.boot.web.server.WebServerFactory

The following examples show how to use org.springframework.boot.web.server.WebServerFactory. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: TeamDojo   Source File: WebConfigurer.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Customize the Servlet engine: Mime types, the document root, the cache.
 */
@Override
public void customize(WebServerFactory server) {
    setMimeMappings(server);
    // When running in an IDE or with ./gradlew bootRun, set location of the static web assets.
    setLocationForStaticAssets(server);

    /*
     * Enable HTTP/2 for Undertow - https://twitter.com/ankinson/status/829256167700492288
     * HTTP/2 requires HTTPS, so HTTP requests will fallback to HTTP/1.1.
     * See the JHipsterProperties class and your application-*.yml configuration files
     * for more information.
     */
    if (jHipsterProperties.getHttp().getVersion().equals(JHipsterProperties.Http.Version.V_2_0) &&
        server instanceof UndertowServletWebServerFactory) {

        ((UndertowServletWebServerFactory) server)
            .addBuilderCustomizers(builder ->
                builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true));
    }
}
 
Example 2
Source Project: albedo   Source File: WebConfigurer.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Customize the Servlet engine: Mime types, the document root, the cache.
 */
@Override
public void customize(WebServerFactory server) {
	setMimeMappings(server);
	// When running in an IDE or with ./mvnw spring-boot:run, set location
	// of the static web assets.
	setLocationForStaticAssets(server);

	/*
	 * Enable HTTP/2 for Undertow - https://twitter.com/ankinson/status/829256167700492288
	 * HTTP/2 requires HTTPS, so HTTP requests will fallback to HTTP/1.1.
	 * See the ApplicationProperties class and your application-*.yml configuration files
	 * for more information.
	 */
	if (applicationProperties.getHttp().getVersion().equals(ApplicationProperties.Http.Version.V_2_0) &&
		server instanceof UndertowServletWebServerFactory) {
		((UndertowServletWebServerFactory) server)
			.addBuilderCustomizers(builder ->
				builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true));
	}

}
 
Example 3
Source Project: seppb   Source File: PortalTomcatWebServerCustomizer.java    License: MIT License 5 votes vote down vote up
@Override
public void customize(WebServerFactory container) {
    TomcatServletWebServerFactory containerFactory = (TomcatServletWebServerFactory) container;
    containerFactory.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> {
        connector.setAttribute("relaxedQueryChars", "[]|{}^\" < > ");
        connector.setAttribute("relaxedPathChars", "[]|");
    });
}
 
Example 4
Source Project: TeamDojo   Source File: WebConfigurer.java    License: Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 5
Source Project: albedo   Source File: WebConfigurer.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
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);
	}
}
 
Example 6
Source Project: jhipster-registry   Source File: WebConfigurer.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Customize the Servlet engine: Mime types, the document root, the cache.
 */
@Override
public void customize(WebServerFactory server) {
    setMimeMappings(server);
    // When running in an IDE or with ./mvnw spring-boot:run, set location of the static web assets.
    setLocationForStaticAssets(server);
}
 
Example 7
Source Project: jhipster-registry   Source File: WebConfigurer.java    License: Apache License 2.0 5 votes vote down vote up
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);
    }
}