| 21165 |
ashik.ali |
1 |
package com.spice.profitmandi.web.config;
|
|
|
2 |
|
| 21220 |
ashik.ali |
3 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 21272 |
kshitij.so |
4 |
import org.springframework.context.annotation.Bean;
|
| 21165 |
ashik.ali |
5 |
import org.springframework.context.annotation.ComponentScan;
|
|
|
6 |
import org.springframework.context.annotation.Configuration;
|
|
|
7 |
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|
|
8 |
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
|
9 |
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
|
10 |
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
|
|
11 |
|
| 21236 |
ashik.ali |
12 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
|
|
13 |
import com.spice.profitmandi.web.interceptor.ApiRequestInterceptor;
|
| 21277 |
ashik.ali |
14 |
import com.spice.profitmandi.web.interceptor.GoogleLoginRequestInterceptor;
|
| 21236 |
ashik.ali |
15 |
import com.spice.profitmandi.web.interceptor.RoleRequestInterceptor;
|
| 21220 |
ashik.ali |
16 |
|
| 21272 |
kshitij.so |
17 |
import springfox.documentation.builders.PathSelectors;
|
|
|
18 |
import springfox.documentation.builders.RequestHandlerSelectors;
|
|
|
19 |
import springfox.documentation.service.ApiInfo;
|
|
|
20 |
import springfox.documentation.spi.DocumentationType;
|
|
|
21 |
import springfox.documentation.spring.web.plugins.Docket;
|
|
|
22 |
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|
|
23 |
|
| 21165 |
ashik.ali |
24 |
@Configuration
|
|
|
25 |
@EnableWebMvc
|
| 21272 |
kshitij.so |
26 |
@EnableSwagger2
|
| 21220 |
ashik.ali |
27 |
@ComponentScan("com.spice.profitmandi.*")
|
| 21165 |
ashik.ali |
28 |
public class WebMVCConfig extends WebMvcConfigurerAdapter{
|
|
|
29 |
|
|
|
30 |
private static final String RESOURCES_PATTERN="/resources/**";
|
|
|
31 |
private static final String RESOURCES_LOCATION="/resources/";
|
|
|
32 |
|
| 21220 |
ashik.ali |
33 |
@Autowired
|
| 21236 |
ashik.ali |
34 |
ApiRequestInterceptor apiRequestInterceptor;
|
| 21165 |
ashik.ali |
35 |
|
| 21236 |
ashik.ali |
36 |
@Autowired
|
|
|
37 |
RoleRequestInterceptor roleRequestInterceptor;
|
|
|
38 |
|
| 21277 |
ashik.ali |
39 |
@Autowired
|
|
|
40 |
GoogleLoginRequestInterceptor googleLoginRequestInterceptor;
|
| 21272 |
kshitij.so |
41 |
|
| 21277 |
ashik.ali |
42 |
|
| 21272 |
kshitij.so |
43 |
@Bean
|
|
|
44 |
public Docket api() {
|
|
|
45 |
return new Docket(DocumentationType.SWAGGER_2).select()
|
|
|
46 |
.apis(RequestHandlerSelectors.any())
|
|
|
47 |
.paths(PathSelectors.any()).build()
|
|
|
48 |
.apiInfo(apiInfo());
|
|
|
49 |
}
|
|
|
50 |
|
| 21165 |
ashik.ali |
51 |
@Override
|
| 21272 |
kshitij.so |
52 |
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
|
53 |
registry.addResourceHandler("swagger-ui.html")
|
|
|
54 |
.addResourceLocations("classpath:/META-INF/resources/");
|
|
|
55 |
registry.addResourceHandler("/webjars/**")
|
|
|
56 |
.addResourceLocations("classpath:/META-INF/resources/webjars/");
|
|
|
57 |
registry.addResourceHandler(RESOURCES_PATTERN).addResourceLocations(RESOURCES_LOCATION);
|
|
|
58 |
}
|
| 21165 |
ashik.ali |
59 |
|
|
|
60 |
@Override
|
|
|
61 |
public void addInterceptors(InterceptorRegistry registry) {
|
| 21236 |
ashik.ali |
62 |
registry.addInterceptor(apiRequestInterceptor).addPathPatterns(ProfitMandiConstants.URL_API, ProfitMandiConstants.URL_API + "/");
|
|
|
63 |
registry.addInterceptor(roleRequestInterceptor).addPathPatterns(ProfitMandiConstants.URL_ROLE, ProfitMandiConstants.URL_ROLE + "/");
|
| 21277 |
ashik.ali |
64 |
registry.addInterceptor(googleLoginRequestInterceptor).addPathPatterns(ProfitMandiConstants.URL_USER_GOOGLE_LOGIN, ProfitMandiConstants.URL_USER_GOOGLE_LOGIN + "/");
|
| 21165 |
ashik.ali |
65 |
}
|
| 21272 |
kshitij.so |
66 |
|
|
|
67 |
private ApiInfo apiInfo() {
|
|
|
68 |
@SuppressWarnings("deprecation")
|
|
|
69 |
ApiInfo apiInfo = new ApiInfo(
|
|
|
70 |
"ProfitMandi API",
|
|
|
71 |
"Api's for profitmandi app",
|
|
|
72 |
"API TOS",
|
|
|
73 |
"Terms of service",
|
|
|
74 |
"New Spice Solutions Pvt. Ltd.",
|
|
|
75 |
"License of API",
|
|
|
76 |
"API license URL");
|
|
|
77 |
return apiInfo;
|
|
|
78 |
}
|
| 21220 |
ashik.ali |
79 |
}
|