package com.bestaone.himall.starter.monitor;

import com.bestaone.himall.starter.monitor.filter. TimeFilter;
import org.springframework.boot.autoconfigure.condition. ConditionalOnProperty;
import org.springframework.boot.web.servlet. FilterRegistrationBean;
import org.springframework.context.annotation. Bean;
import org.springframework.context.annotation. Configuration;

import java.util. ArrayList;
import java.util. List;

@Configuration
@ConditionalOnProperty(prefix = "himall.monitor", name = "enable", havingValue = "true")
public class MonitorConfig {

    @Bean
    public FilterRegistrationBean filterRegistrationBean() {
        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        TimeFilter timeFilter = new TimeFilter();
        registrationBean.setFilter(timeFilter);
        List<String> urls = new ArrayList<>();
        urls.add("/*");
        registrationBean.setUrlPatterns(urls);
        return registrationBean;
    }

}