You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.5 KiB
42 lines
1.5 KiB
package com.dji.sample.configuration.mvc; |
|
|
|
import com.dji.sample.component.AuthInterceptor; |
|
import org.springframework.beans.factory.annotation.Autowired; |
|
import org.springframework.beans.factory.annotation.Value; |
|
import org.springframework.context.annotation.Configuration; |
|
import org.springframework.web.method.support.HandlerMethodArgumentResolver; |
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
|
|
|
import java.util.ArrayList; |
|
import java.util.List; |
|
|
|
@Configuration |
|
public class GlobalMVCConfigurer implements WebMvcConfigurer { |
|
|
|
@Autowired |
|
private AuthInterceptor authInterceptor; |
|
|
|
private static List<String> excludePaths = new ArrayList<>(); |
|
|
|
@Value("${url.manage.prefix}") |
|
private String managePrefix; |
|
|
|
@Value("${url.manage.version}") |
|
private String manageVersion; |
|
|
|
|
|
@Override |
|
public void addInterceptors(InterceptorRegistry registry) { |
|
// Exclude the login interface. |
|
excludePaths.add(managePrefix + manageVersion + "/login"); |
|
excludePaths.add(managePrefix + manageVersion + "/token/refresh"); |
|
// Intercept for all request interfaces. |
|
registry.addInterceptor(authInterceptor).addPathPatterns("/**").excludePathPatterns(excludePaths); |
|
} |
|
|
|
@Override |
|
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) { |
|
resolvers.add(new GetSnakeArgumentProcessor(true)); |
|
} |
|
}
|
|
|