dragon-zhang opened a new issue #3025:
URL: https://github.com/apache/incubator-shenyu/issues/3025


   ### Question
   
   In 
`org.apache.shenyu.plugin.general.context.GeneralContextPlugin#doExecute`, just 
like below:
   ```java
       protected Mono<Void> doExecute(final ServerWebExchange exchange, final 
ShenyuPluginChain chain, final SelectorData selector, final RuleData rule) {
           Map<String, List<GeneralContextHandle>> generalContextHandleMap = 
GeneralContextPluginDataHandler.CACHED_HANDLE.get().obtainHandle(CacheKeyUtils.INST.getKey(rule));
           Map<String, Map<String, String>> generalContextMap = new HashMap<>();
           HttpHeaders headers = exchange.getRequest().getHeaders();
           generalContextHandleMap.forEach((rpcType, v) -> {
               if (CollectionUtils.isEmpty(v)) {
                   return;
               }
               Map<String, String> generalContextMapWithRpcType = new 
HashMap<>();
               v.forEach(each -> {
                   if (StringUtils.isBlank(each.getGeneralContextType()) || 
StringUtils.isBlank(each.getGeneralContextKey())) {
                       return;
                   }
                   switch (each.getGeneralContextType()) {
                       case Constants.ADD_GENERAL_CONTEXT_TYPE:
                           
generalContextMapWithRpcType.put(each.getGeneralContextKey(), 
each.getGeneralContextValue());
                           break;
                       case Constants.TRANSMIT_HEADER_TO_GENERAL_CONTEXT_TYPE:
                           
generalContextMapWithRpcType.put(StringUtils.isBlank(each.getGeneralContextValue())
 ? each.getGeneralContextKey() : each.getGeneralContextValue(),
                                   
headers.getFirst(each.getGeneralContextKey()));
                           break;
                       default:
                           break;
                   }
               });
               // put the request header from the front end into the 
`generalContextMapWithRpcType`
               exchange.getRequest().getHeaders().forEach((k, val) -> 
generalContextMapWithRpcType.put(k, String.join(", ", val)));
               generalContextMap.put(rpcType, generalContextMapWithRpcType);
           });
           exchange.getAttributes().put(Constants.GENERAL_CONTEXT, 
generalContextMap);
           return chain.execute(exchange);
       }
   ```


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to