This is an automated email from the ASF dual-hosted git repository.

xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new 5bd99ef149 [type:bugfix] springCloud ruleData path setting didn't used 
#5840 (#5843)
5bd99ef149 is described below

commit 5bd99ef14906d3f53eb3fb5a628470968169307c
Author: frank <shaoshuai...@163.com>
AuthorDate: Wed Dec 11 10:14:40 2024 +0800

    [type:bugfix] springCloud ruleData path setting didn't used #5840 (#5843)
    
    * [type:bugfix] springCloud ruleData path setting didn't used #5840
    
    * [type:bugfix] springCloud ruleData path setting didn't used #5840
    
    ---------
    
    Co-authored-by: xiaoyu <xia...@apache.org>
---
 .../apache/shenyu/plugin/springcloud/SpringCloudPlugin.java  | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git 
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-springcloud/src/main/java/org/apache/shenyu/plugin/springcloud/SpringCloudPlugin.java
 
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-springcloud/src/main/java/org/apache/shenyu/plugin/springcloud/SpringCloudPlugin.java
index 0bb96105fb..034b6f8473 100644
--- 
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-springcloud/src/main/java/org/apache/shenyu/plugin/springcloud/SpringCloudPlugin.java
+++ 
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-springcloud/src/main/java/org/apache/shenyu/plugin/springcloud/SpringCloudPlugin.java
@@ -48,7 +48,7 @@ import java.util.Objects;
 public class SpringCloudPlugin extends AbstractShenyuPlugin {
 
     private final ShenyuSpringCloudServiceChooser serviceChooser;
-    
+
     /**
      * Instantiates a new Spring cloud plugin.
      *
@@ -57,7 +57,7 @@ public class SpringCloudPlugin extends AbstractShenyuPlugin {
     public SpringCloudPlugin(final ShenyuSpringCloudServiceChooser 
serviceInstanceChooser) {
         this.serviceChooser = serviceInstanceChooser;
     }
-    
+
     @Override
     protected String getRawPath(final ServerWebExchange exchange) {
         return RequestUrlUtils.getRewrittenRawPath(exchange);
@@ -85,7 +85,11 @@ public class SpringCloudPlugin extends AbstractShenyuPlugin {
             return WebFluxResultUtils.result(exchange, error);
         }
         final String domain = upstream.buildDomain();
-        setDomain(URI.create(domain + 
(StringUtils.isBlank(ruleHandle.getPath()) ? shenyuContext.getRealUrl() : 
ruleHandle.getPath())), exchange);
+        //if rule data has path,its realUrl.
+        if (StringUtils.isNotBlank(ruleHandle.getPath())) {
+            shenyuContext.setRealUrl(ruleHandle.getPath());
+        }
+        setDomain(URI.create(domain + shenyuContext.getRealUrl()), exchange);
         //set time out.
         exchange.getAttributes().put(Constants.HTTP_TIME_OUT, 
ruleHandle.getTimeout());
         return chain.execute(exchange);
@@ -121,7 +125,7 @@ public class SpringCloudPlugin extends AbstractShenyuPlugin 
{
     protected Mono<Void> handleRuleIfNull(final String pluginName, final 
ServerWebExchange exchange, final ShenyuPluginChain chain) {
         return WebFluxResultUtils.noRuleResult(pluginName, exchange);
     }
-    
+
     private SpringCloudRuleHandle buildRuleHandle(final RuleData rule) {
         return 
SpringCloudPluginDataHandler.RULE_CACHED.get().obtainHandle(CacheKeyUtils.INST.getKey(rule));
     }

Reply via email to