|
|
|
@ -1,7 +1,11 @@
|
|
|
|
package cn.iocoder.mall.dubbo.core.web;
|
|
|
|
package cn.iocoder.mall.dubbo.core.web;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.common.framework.util.StringUtils;
|
|
|
|
import cn.iocoder.common.framework.util.StringUtils;
|
|
|
|
|
|
|
|
import cn.iocoder.mall.dubbo.core.cluster.interceptor.DubboConsumerRouterTagClusterInterceptor;
|
|
|
|
|
|
|
|
import cn.iocoder.mall.dubbo.core.filter.DubboProviderRouterTagFilter;
|
|
|
|
import cn.iocoder.mall.dubbo.core.router.DubboRouterTagContextHolder;
|
|
|
|
import cn.iocoder.mall.dubbo.core.router.DubboRouterTagContextHolder;
|
|
|
|
|
|
|
|
import org.apache.dubbo.common.constants.CommonConstants;
|
|
|
|
|
|
|
|
import org.apache.dubbo.rpc.RpcContext;
|
|
|
|
import org.springframework.web.servlet.HandlerInterceptor;
|
|
|
|
import org.springframework.web.servlet.HandlerInterceptor;
|
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
|
|
|
|
|
|
@ -11,7 +15,8 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Dubbo 路由标签的 Web 拦截器,将请求 Header 中的 {@link #HEADER_DUBBO_TAG} 设置到 {@link DubboRouterTagContextHolder} 中。
|
|
|
|
* Dubbo 路由标签的 Web 拦截器,将请求 Header 中的 {@link #HEADER_DUBBO_TAG} 设置到 {@link DubboRouterTagContextHolder} 中。
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @see cn.iocoder.mall.dubbo.core.filter.DubboRouterTagFilter
|
|
|
|
* @see DubboProviderRouterTagFilter
|
|
|
|
|
|
|
|
* @see DubboConsumerRouterTagClusterInterceptor
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class DubboRouterTagWebInterceptor implements HandlerInterceptor {
|
|
|
|
public class DubboRouterTagWebInterceptor implements HandlerInterceptor {
|
|
|
|
|
|
|
|
|
|
|
|
@ -22,6 +27,7 @@ public class DubboRouterTagWebInterceptor implements HandlerInterceptor {
|
|
|
|
String tag = request.getHeader(HEADER_DUBBO_TAG);
|
|
|
|
String tag = request.getHeader(HEADER_DUBBO_TAG);
|
|
|
|
if (StringUtils.hasText(tag)) {
|
|
|
|
if (StringUtils.hasText(tag)) {
|
|
|
|
DubboRouterTagContextHolder.setTag(tag);
|
|
|
|
DubboRouterTagContextHolder.setTag(tag);
|
|
|
|
|
|
|
|
RpcContext.getContext().setAttachment(CommonConstants.TAG_KEY, tag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|