/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 */
package com.jeesite.modules;

import com.beust.jcommander.internal.Maps;
import com.jeesite.filter.SenFilter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;

import java.util.Map;

/**
 * Application
 * @author ThinkGem
 * @version 2018-10-13
 */
@SpringBootApplication
public class Application extends SpringBootServletInitializer {

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
		this.setRegisterErrorPageFilter(false); // 错误页面有容器来处理，而不是SpringBoot
		System.out.println();
	return builder.sources(Application.class);
	}


	@Bean
	public FilterRegistrationBean senFilterRegistration() {
		FilterRegistrationBean registration = new FilterRegistrationBean();
		registration.setFilter(new SenFilter());
		registration.addUrlPatterns("/*");
		registration.setName("senFilter");
		registration.setOrder(2);
		Map<String, String> initParameters = Maps.newHashMap();
		//-excludes用于配置不需要参数过滤的请求url;
		//-isIncludeRichText默认为true，主要用于设置富文本内容是否需要过滤。
		initParameters.put("excludes", "/favicon.ico,/img/*,/js/*,/css/*");
		initParameters.put("isIncludeRichText", "true");
		registration.setInitParameters(initParameters);
		return registration;
	}
}
