package cn.superdesk.uniorder.config;

import org.apache.catalina.Context;
import org.apache.tomcat.util.http.LegacyCookieProcessor;
import org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.stereotype.Component;

/**
 * @Description: Java类作用描述
 * @Author: linjinyu
 * @CreateDate: 8/20/20 7:38 PM
 * @UpdateUser: linjinyu
 * @UpdateDate: 8/20/20 7:38 PM
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Component
public class EmbeddedTomcatConfig implements WebServerFactoryCustomizer {


//	@Override
//	public void customize(ConfigurableServletWebServerFactory factory) {
//		((TomcatServletWebServerFactory) factory).addContextCustomizers(new TomcatContextCustomizer() {
//			@Override
//			public void customize(Context context) {
//				context.setCookieProcessor(new LegacyCookieProcessor());
//			}
//		});
//	}

	@Override
	public void customize(WebServerFactory factory) {
		((TomcatServletWebServerFactory) factory).addContextCustomizers(new TomcatContextCustomizer() {
			@Override
			public void customize(Context context) {
				context.setCookieProcessor(new LegacyCookieProcessor());
			}
		});
	}
}