All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cloud.lego.web.spring.boot.autoconfigure.WebLogAutoConfiguration Maven / Gradle / Ivy

package com.cloud.lego.web.spring.boot.autoconfigure;

import com.cloud.lego.web.spring.boot.autoconfigure.constants.OrderConstants;
import com.cloud.lego.web.spring.boot.core.log.LogInterceptor;
import com.cloud.lego.web.spring.boot.core.properties.LogCookieProperties;
import jakarta.annotation.Resource;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import static com.cloud.lego.constants.spring.boot.web.WebConstants.STATIC_RESOURCE_URLS;

/**
 * 打印请求响应日志
 *
 * @author Andy
 */
@AutoConfiguration
@ConditionalOnWebApplication
@EnableConfigurationProperties(LogCookieProperties.class)
public class WebLogAutoConfiguration implements WebMvcConfigurer {

    @Resource
    private LogCookieProperties logCookieProperties;

    /**
     * 配置拦截器
     *
     * @param registry 拦截器注册器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LogInterceptor(logCookieProperties))
                .order(OrderConstants.Interceptor.WEB_REQUEST_LOG).addPathPatterns("/**")
                .excludePathPatterns(STATIC_RESOURCE_URLS);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy