package lan.dk.podcastserver.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.web.config.EnableSpringDataWebSupport;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.resource.GzipResourceResolver;

/**
 * Configuration de la partie Web MVC de l'application
 * Plus d'informations sur le configuration Java-Config de Spring MVC : http://www.luckyryan.com/2013/02/07/migrate-spring-mvc-servlet-xml-to-java-config/
 */
@Configuration
@ComponentScan("lan.dk.podcastserver.controller")
@EnableSpringDataWebSupport
public class WebMvcConfig extends WebMvcConfigurerAdapter {

    private static final int CACHE_PERIOD = 31556926;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        GzipResourceResolver gzipResourceResolver = new GzipResourceResolver();

        registry
                .addResourceHandler("*.js", "*.css", "*.js.min", "*.css.min")
                .addResourceLocations("classpath:/static/")
                .setCachePeriod(CACHE_PERIOD)
                .resourceChain(true)
                .addResolver(gzipResourceResolver);

        registry
                .addResourceHandler("fonts/*.woff", "fonts/*.woff2", "fonts/*.eot", "fonts/*.svg", "fonts/*.ttf")
                .addResourceLocations("classpath:/static/fonts/")
                .setCachePeriod(CACHE_PERIOD)
                .resourceChain(true)
                .addResolver(gzipResourceResolver);
    }

    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }
}

@@ -469,23 +469,16 @@
 nfigurer
-Adapter
 ;%0Aimport
@@ -883,14 +883,17 @@
 fig 
-extend
+implement
 s We
@@ -910,15 +910,8 @@
 urer
-Adapter
  %7B%0A%0A

move to WebMvcConfigurer due to deprecated of the standard adapter