Baoyuantop commented on code in PR #12187:
URL: https://github.com/apache/apisix/pull/12187#discussion_r2221663611


##########
apisix/core/utils.lua:
##########
@@ -461,5 +461,4 @@ function _M.check_tls_bool(fields, conf, plugin_name)
     end
 end
 
-

Review Comment:
   This change is not necessary.



##########
docs/en/latest/discovery.md:
##########
@@ -216,6 +216,35 @@ Server: APISIX web server
 {"node":{"value":{"uri":"\/user\/*","upstream": {"service_name": 
"USER-SERVICE", "type": "roundrobin", "discovery_type": 
"eureka"}},"createdIndex":61925,"key":"\/apisix\/routes\/1","modifiedIndex":61925}}
 ```
 
+You can also use variables in the service name. For example, to route requests 
based on the host header using nginx map:
+
+First, configure the map in your nginx configuration:
+
+```nginx
+map $http_host $backend {
+    hostnames;
+    default service_a;
+    x.domain.local service_x;
+    y.domain.local service_y;
+}
+```
+
+Then use the mapped variable in your route configuration:
+
+```shell
+$ curl http://127.0.0.1:9180/apisix/admin/routes/1 -H "X-API-KEY: $admin_key" 
-X PUT -i -d '
+{
+    "uri": "/*",
+    "upstream": {
+        "service_name": "${backend}",
+        "type": "roundrobin",
+        "discovery_type": "eureka"
+    }
+}'
+```
+
+In this example, requests to `x.domain.local` will be routed to the service 
named "service_a", while requests to `y.domain.local` will be routed to 
"service_b".

Review Comment:
   Should this be service_x and service_y ?



##########
t/discovery/consul.t:
##########
@@ -26,7 +26,6 @@ add_block_preprocessor(sub {
     my ($block) = @_;
 
     my $http_config = $block->http_config // <<_EOC_;
-

Review Comment:
   Unnecessary changes



-- 
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-unsubscr...@apisix.apache.org

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

Reply via email to