package br.gov.servicos.editor.config;

import org.apache.coyote.http11.AbstractHttp11Protocol;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.CharacterEncodingFilter;

import javax.servlet.Filter;

import static org.apache.commons.lang3.StringUtils.join;

@Configuration
public class ServletContainerConfig {

    public static final String COMPRESSIBLE_MEDIA_TYPES = join(new String[]{
            "text/html",
            "text/xml",
            "text/plain",
            "application/json",
            "application/javascript",
            "text/css"
    }, ',');

    @Bean
    public EmbeddedServletContainerCustomizer servletContainerCustomizer() {
        return servletContainer -> {
            TomcatEmbeddedServletContainerFactory container = (TomcatEmbeddedServletContainerFactory) servletContainer;

            container.setRegisterJspServlet(false);

            container.addContextCustomizers(customizer -> customizer.addWelcomeFile("index.html"));
            container.addConnectorCustomizers(
                    connector -> {
                        AbstractHttp11Protocol httpProtocol = (AbstractHttp11Protocol) connector.getProtocolHandler();
                        httpProtocol.setCompression("on");
                        httpProtocol.setCompressionMinSize(256);
                        httpProtocol.setCompressableMimeTypes(COMPRESSIBLE_MEDIA_TYPES);
                    }
            );
        };
    }

    @Bean
    public Filter characterEncodingFilter() {
        CharacterEncodingFilter filter = new CharacterEncodingFilter();
        filter.setEncoding("UTF-8");
        filter.setForceEncoding(true);

        return filter;
    }

}

@@ -142,42 +142,192 @@
 ded.
-EmbeddedServletContainerCustomizer
+ConfigurableEmbeddedServletContainer;%0Aimport org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;%0Aimport org.springframework.boot.context.embedded.MimeMappings
 ;%0Aim
@@ -960,16 +960,55 @@
 cript%22,%0A
+            %22application/x-font-woff%22,%0A
         
@@ -1156,24 +1156,80 @@
 tainer -%3E %7B%0A
+            addMimeMappingsForFonts(servletContainer);%0A%0A
             
@@ -1959,16 +1959,526 @@
 %0A    %7D%0A%0A
+    private void addMimeMappingsForFonts(ConfigurableEmbeddedServletContainer servletContainer) %7B%0A        MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);%0A        mappings.add(%22eot%22, %22application/vnd.ms-fontobject%22);%0A        mappings.add(%22ttf%22, %22application/font-sfnt%22);%0A        mappings.add(%22otf%22, %22application/font-sfnt%22);%0A        mappings.add(%22woff%22, %22application/font-woff%22);%0A        mappings.add(%22woff2%22, %22application/font-woff%22);%0A        servletContainer.setMimeMappings(mappings);%0A    %7D%0A%0A
     @Bea
@@ -2630,24 +2630,24 @@
 g(%22UTF-8%22);%0A
+
         filt
@@ -2669,25 +2669,24 @@
 ding(true);%0A
-%0A
         retu

Configura tipos MIME para fontes