You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "carlvine500 (via GitHub)" <gi...@apache.org> on 2023/06/14 15:28:13 UTC

[GitHub] [dubbo] carlvine500 commented on a diff in pull request #12514: add spring boot interceptor to copy header(dubbo-tag)/cookie(dubbo.tag)

carlvine500 commented on code in PR #12514:
URL: https://github.com/apache/dubbo/pull/12514#discussion_r1229811928


##########
dubbo-spring-boot/dubbo-spring-boot-interceptor/src/main/java/org/apache/dubbo/spring/boot/interceptor/DubboTagCookieInterceptor.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.spring.boot.interceptor;
+
+import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.rpc.RpcContext;
+import org.springframework.web.servlet.HandlerInterceptor;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class DubboTagCookieInterceptor implements HandlerInterceptor {
+
+    @Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+        String tag = getSingleCookieValue(request.getCookies(), CommonConstants.TAG_KEY);

Review Comment:
   我们公司测试同学会对不同的功能集打不同的标签,例如tag需要发布微服务a->b->c->d中的 a(tag1)和c(tag1), 然后测试同学只需要在chrome浏览器插件中设置cookie(dubbo.tag=tag1)就能访问到开发的a(tag1)和c(tag1) , 通常这个测试会持续较很多天, 只要cookie保存在浏览器中就行,必要时还可以切换其它的tag2/tag3测试 . 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org