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.
43 lines
1.5 KiB
43 lines
1.5 KiB
3 years ago
|
package com.dji.sample.configuration.mvc;
|
||
3 years ago
|
|
||
|
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;
|
||
3 years ago
|
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||
3 years ago
|
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;
|
||
|
|
||
3 years ago
|
|
||
3 years ago
|
@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);
|
||
|
}
|
||
3 years ago
|
|
||
|
@Override
|
||
|
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
|
||
|
resolvers.add(new GetSnakeArgumentProcessor(true));
|
||
|
}
|
||
3 years ago
|
}
|