Skip to content

Commit

Permalink
refactor to rust code mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
damonxue committed Oct 11, 2024
1 parent 49f9603 commit e8dfd9d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 23 deletions.
30 changes: 18 additions & 12 deletions shenyuClientRust/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ shenyu:
password: "123456"
```
```markdown
//init config.
let config = ShenYuConfig::from_yaml_file("config.yml").unwrap();
// init shenyu client.
let client = ShenyuClient::new(config, app.app_name(), app.uri_infos(), 3000).unwrap();
```rust
fn register_test() {
//init config.
let config = ShenYuConfig::from_yaml_file("config.yml").unwrap();
// init shenyu client.
let client = ShenyuClient::new(config, app.app_name(), app.uri_infos(), 3000).unwrap();
/// other steps.
}
```

```log
```
The adminToken like this :
{
"code":200,
Expand All @@ -49,19 +52,22 @@ The adminToken like this :
"enabled":true,
"dateCreated":"2018-06-23 15:12:22",
"dateUpdated":"2024-10-03 02:29:39",
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyTmFtZSI6ImFkbWluIiwiZXhwIjoxNjUwNjc5OTQ2fQ.K92Il2kmJ0X3FgjY4igW35-pw9nsf5VKdUyqBoyIaF4"
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyTmFtZSI6ImFkbWluIiwiZXhwIjoxNzI4NTQ3NjQ3fQ.93LAuDP_MrJZeQB5A6gX-3-Vyxy9egw41QhnNHlUWEE"
}
}
When you success get toekn, you will see this :
this is ShenYu Admin client token -> eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyTmFtZSI6ImFkbWluIiwiZXhwIjoxNjUwNjc5OTQ2fQ.K92Il2kmJ0X3FgjY4igW35-pw9nsf5VKdUyqBoyIaF4
2024-10-09T08:07:27.721483Z INFO shenyu_client_rust::core: [SUCCESS], get register token success, register token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyTmFtZSI6ImFkbWluIiwiZXhwIjoxNzI4NTQ3NjQ3fQ.93LAuDP_MrJZeQB5A6gX-3-Vyxy9egw41QhnNHlUWEE"
```

**3.Step 2 Register MetaData to ShenYu GateWay.**
**3.Step 2 Register to ShenYu admin. (maybe add the admin sync data to gateway doc url).**

```markdown
// register to shenyu admin.
client.register().expect("TODO: panic message");
```rust
fn register_test() {
/// Step1.
// register to shenyu admin.
client.register().expect("TODO: panic message");
}
```

```log
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ shenyu:
password: "123456"
```
```markdown
//init config.
let config = ShenYuConfig::from_yaml_file("config.yml").unwrap();
// init shenyu client.
let client = ShenyuClient::new(config, app.app_name(), app.uri_infos(), 3000).unwrap();
```rust
fn register_test() {
//init config.
let config = ShenYuConfig::from_yaml_file("config.yml").unwrap();
// init shenyu client.
let client = ShenyuClient::new(config, app.app_name(), app.uri_infos(), 3000).unwrap();
/// other steps.
}
```

```
Expand All @@ -57,11 +60,14 @@ When you success get toekn, you will see this :
2024-10-09T08:07:27.721483Z INFO shenyu_client_rust::core: [SUCCESS], get register token success, register token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyTmFtZSI6ImFkbWluIiwiZXhwIjoxNzI4NTQ3NjQ3fQ.93LAuDP_MrJZeQB5A6gX-3-Vyxy9egw41QhnNHlUWEE"
```

**3.Step 2 Register MetaData to ShenYu GateWay.**
**3.Step 2 Register to ShenYu admin. (maybe add the admin sync data to gateway doc url).**

```markdown
// register to shenyu admin.
client.register().expect("TODO: panic message");
```rust
fn register_test() {
/// Step1.
// register to shenyu admin.
client.register().expect("TODO: panic message");
}
```

```log
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"version-1.0.0/tutorialSidebar": [
"version-0.2.0/tutorialSidebar": [
{
"type": "autogenerated",
"dirName": "."
}
]
}

0 comments on commit e8dfd9d

Please sign in to comment.