You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2020/09/11 08:05:37 UTC

[GitHub] [skywalking] Lumia001 commented on issue #3294: rest protocol of dubbo not supported

Lumia001 commented on issue #3294:
URL: https://github.com/apache/skywalking/issues/3294#issuecomment-690943314


   Surprisingly ! 
    I meet the same problem......In dubbo's rest protocal, before the RpcContextFilter of implements ContainerRequestFilter  sets header's k/v into  RpcContext's Attachment, require value must be contain '=' or ',' .
   
   For this situation, I can't give up dubbo' rest protocal or SW. 
   
   So, make something to figure it out.
   
   Here is a complete and perfect solution !
   
   First:
   ---------------------part one---------------------------
   @Provider
   @Priority(Priorities.HEADER_DECORATOR )
   public class SwClientFilter implements ClientRequestFilter {
   
       @Override
       public void filter(ClientRequestContext requestContext) throws IOException {
           for (Map.Entry<String, String> entry : RpcContext.getContext().getAttachments().entrySet()) {
               if (entry.getKey().equals("sw6")){
                   String value = entry.getValue();
                   String replaceAll= value.replaceAll("=", "%");
                   entry.setValue(replaceAll);
                   return;
               }
           }
       }
   }
   
   -----------------------------part two.--------------------------
   @Provider
   @Priority(Integer.MIN_VALUE + 20)
   public class SwContainerFilter implements ContainerRequestFilter {
   
       @Override
       public void filter(ContainerRequestContext requestContext) {
           for (Map.Entry<String, String> entry : RpcContext.getContext().getAttachments().entrySet()) {
               if (entry.getKey().equals("sw6")){
                   String value = entry.getValue();
                   String replaceAll= value.replaceAll("%", "=");
                   entry.setValue(replaceAll);
                   return;
               }
           }
       }
   }
   
   
   Then:
   
   add custom filter in <dubbo:protocal extension="........................">
   
   
   
   Welcom to try it ~
   
   


----------------------------------------------------------------
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.

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