Skip to content

Commit

Permalink
support empty namespace id.
Browse files Browse the repository at this point in the history
  • Loading branch information
damonxue committed Jan 2, 2025
1 parent 34e7f88 commit 7b64c38
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/actix-web-example/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ shenyu:
register:
register_type: "http"
servers: "http://127.0.0.1:9095"
namespace_id: "testNamespaceId"
namespace_id: "649330b6-c2d7-4edc-be8e-8a54df9eb385"
props:
username: "admin"
password: "123456"
Expand Down
2 changes: 1 addition & 1 deletion examples/axum-example/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ shenyu:
register:
register_type: "http"
servers: "http://127.0.0.1:9095"
namespace_id: "testNamespaceId"
namespace_id: ""
props:
username: "admin"
password: "123456"
Expand Down
12 changes: 8 additions & 4 deletions shenyu-client-rust/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,14 @@ impl ShenyuClient {
"Content-Type".to_string(),
"application/json;charset=UTF-8".to_string(),
);
let namespace_ids: Vec<String> = config.register.namespace_id.clone().map_or(
vec![SYS_DEFAULT_NAMESPACE_ID.to_string()],
|x| -> Vec<String> { x.split(';').map(ToString::to_string).collect() },
);
let namespace_ids: Vec<String> = config
.register
.namespace_id
.clone()
.filter(|x| !x.is_empty())
.map_or(vec![SYS_DEFAULT_NAMESPACE_ID.to_string()], |x| {
x.split(';').map(ToString::to_string).collect()
});

let mut client = ShenyuClient {
headers,
Expand Down

0 comments on commit 7b64c38

Please sign in to comment.