package com.liquidnet.common.web.config;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**").addResourceLocations(
                "classpath:/static/");
        registry.addResourceHandler("doc.html").addResourceLocations(
                "classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**").addResourceLocations(
                "classpath:/META-INF/resources/webjars/");
        registry.addResourceHandler("*.js").addResourceLocations(
                "/webapp/js/**");
        registry.addResourceHandler("*.css").addResourceLocations(
                "webapp/css/**");
        registry.addResourceHandler("*.img").addResourceLocations(
                "webapp/img/**");
        super.addResourceHandlers(registry);
    }

//    @Bean
//    public FilterRegistrationBean domainCrossFilterBean(){
//        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
//        CrossDomainFilter filter = new CrossDomainFilter();
//        registrationBean.setFilter(filter);
//        registrationBean.addUrlPatterns("/*");
//        return registrationBean;
//    }
}
