package me.chyxion.tigon.webmvc.war;

import org.springframework.context.annotation.Configuration;
import me.chyxion.tigon.webmvc.TigonWebMvcConfiguration;
import org.springframework.web.servlet.mvc.WebContentInterceptor;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;

/**
 * @author Donghuang <br>
 * donghuang@wacai.com <br>
 * Apr 09, 2017 14:28:20
 */
@Configuration
@EnableAspectJAutoProxy
public class TigonWebMvcWarConfig extends TigonWebMvcConfiguration {

    /**
     * {@inheritDoc}
     */
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new WebContentInterceptor())
            .excludePathPatterns("/assets/**", "classpath:webapp/assets/**");
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/assets/**")
            .addResourceLocations("/assets/", "classpath:webapp/assets/");
    }
}
