| | |
| | | package com.zy.asrs.wms.common.config; |
| | | |
| | | import com.zy.asrs.wms.common.constant.Constants; |
| | | import com.zy.asrs.wms.utils.Utils; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.web.servlet.AsyncHandlerInterceptor; |
| | | import org.springframework.web.servlet.config.annotation.CorsRegistry; |
| | | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
| | | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * Created by vincent on 2019-06-13 |
| | | */ |
| | | @Configuration |
| | | public class WebConfig implements WebMvcConfigurer { |
| | | |
| | | @Override |
| | | public void addInterceptors(InterceptorRegistry registry) { |
| | | registry.addInterceptor(getAsyncHandlerInterceptor()) |
| | | .addPathPatterns("/**") |
| | | ; |
| | | } |
| | | |
| | | @Bean |
| | | public AsyncHandlerInterceptor getAsyncHandlerInterceptor() { |
| | | return new AsyncHandlerInterceptor(){ |
| | | @Override |
| | | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { |
| | | Utils.cors(response); |
| | | return true; |
| | | } |
| | | }; |
| | | } |
| | | |
| | | @Override |
| | | public void addCorsMappings(CorsRegistry registry) { |
| | | registry.addMapping("/**") |
| | | .allowedOriginPatterns("*") |
| | | .allowedHeaders("*") |
| | | .exposedHeaders(Constants.TOKEN_HEADER_NAME) |
| | | .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH") |
| | | .allowCredentials(true) |
| | | .maxAge(3600); |
| | | } |
| | | |
| | | } |
| | | package com.zy.asrs.wms.common.config;
|
| | |
|
| | | import com.zy.asrs.wms.common.constant.Constants;
|
| | | import com.zy.asrs.wms.utils.Utils;
|
| | | import org.springframework.context.annotation.Bean;
|
| | | import org.springframework.context.annotation.Configuration;
|
| | | import org.springframework.web.servlet.AsyncHandlerInterceptor;
|
| | | import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
| | | import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
| | | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
| | |
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | /**
|
| | | * Created by vincent on 2019-06-13
|
| | | */
|
| | | @Configuration
|
| | | public class WebConfig implements WebMvcConfigurer {
|
| | |
|
| | | @Override
|
| | | public void addInterceptors(InterceptorRegistry registry) {
|
| | | registry.addInterceptor(getAsyncHandlerInterceptor())
|
| | | .addPathPatterns("/**")
|
| | | ;
|
| | | }
|
| | |
|
| | | @Bean
|
| | | public AsyncHandlerInterceptor getAsyncHandlerInterceptor() {
|
| | | return new AsyncHandlerInterceptor(){
|
| | | @Override
|
| | | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
| | | Utils.cors(response);
|
| | | return true;
|
| | | }
|
| | | };
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void addCorsMappings(CorsRegistry registry) {
|
| | | registry.addMapping("/**")
|
| | | .allowedOriginPatterns("*")
|
| | | .allowedHeaders("*")
|
| | | .exposedHeaders(Constants.TOKEN_HEADER_NAME)
|
| | | .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH")
|
| | | .allowCredentials(true)
|
| | | .maxAge(3600);
|
| | | }
|
| | |
|
| | | }
|