package digital.laboratory.platform.entrustment.Interceptor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * URL拦截, 做对应处理
 *
 */
@Component
public class URLInterceptor implements HandlerInterceptor {

	private static final Logger logger = LoggerFactory.getLogger(URLInterceptor.class);

	/**
	 * 请求前置处理（后置处理同理）
	 *
	 * @param request
	 * @param response
	 * @param handler
	 * @return boolean
	 */
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		String path = request.getServletPath();
System.out.println(String.format("(entrustment 中的URL拦截) Request ---> Path=%s", path));
return true;
//		logger.info(path);
//		if (path.matches("xxxxx")) {
//			logger.info("requestUrl: {}", path);
//			// 进行前置处理
//			return true;
//			// 或者 return false; 禁用某些请求
//		} else {
//			return true;
//		}
	}
}

