package com.nokia.tsl_data.util.logging;

import org.springframework.lang.Nullable;
import org.springframework.web.servlet.DispatcherServlet;

import com.nokia.tsl_data.util.logging.entity.RepeatableHttpServletRequestWrapper;
import com.nokia.tsl_data.util.logging.entity.RepeatableHttpServletResponseWrapper;

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

/**
 * 自定义DispatcherServlet
 */
public class RequestLogDispatcherServlet extends DispatcherServlet {

    /**
     * 使用可重复读的reuqest和respone替换原来参数
     */
    @Override
    protected void doDispatch(@Nullable HttpServletRequest request, @Nullable HttpServletResponse response) throws Exception {
        super.doDispatch(new RepeatableHttpServletRequestWrapper(request),
                new RepeatableHttpServletResponseWrapper(response));
    }

}
