package org.ta.pddserver.config;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.ta.pddserver.utils.JsonResponse;

import java.io.IOException;

@WebFilter(
        urlPatterns = {"/hj-api/*"}, filterName = "apiFilter"
)
@Order(1)
@Slf4j
public class APIFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        Filter.super.init(filterConfig);
        log.info("API 过滤器初始化");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        log.info("API 开始处理请求，过滤数据");

        HttpServletRequest  request = (HttpServletRequest) servletRequest;
        String url = request.getRequestURI();
        log.info("url = {}", url);
        filterChain.doFilter(servletRequest, servletResponse);

    }


}
