Skip to content

Commit 999fe6c

Browse files
committed
refactor(rust:chat): Fix rust version update, code can not run.
TODO: Fix reqwest get bug, can not get data from server yet.
1 parent 00e883a commit 999fe6c

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

rust/chat/src/main.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,26 @@ fn main () {
1515
let mut resp = reqwest::get("http://[::]:12345/api/room/1").unwrap();
1616
let mut t = term::stdout().unwrap();
1717
if resp.status().is_success() {
18-
resp.copy_to(&mut t);
18+
let r = resp.copy_to(&mut t);
19+
match r {
20+
Err(e) => println!("{:?}", e),
21+
_ => ()
22+
}
1923
} else if resp.status().is_server_error() {
2024
t.fg(term::color::RED).unwrap();
21-
write!(t, "Server error! Status: {:?}", resp.status());
25+
let r = write!(t, "Server error! Status: {:?}", resp.status());
26+
match r {
27+
Err(e) => println!("{:?}", e),
28+
_ => ()
29+
}
2230
t.reset().unwrap();
2331
} else {
2432
t.fg(term::color::CYAN).unwrap();
25-
write!(t, "Something else happened. Status: {:?}", resp.status());
33+
let r = write!(t, "Something else happened. Status: {:?}", resp.status());
34+
match r {
35+
Err(e) => println!("{:?}", e),
36+
_ => ()
37+
}
2638
t.reset().unwrap();
2739
}
2840
}
@@ -40,7 +52,7 @@ fn main () {
4052
let mut whom = String::from(name);
4153
whom.push_str(": ");
4254
whom.push_str(&line.clone());
43-
client.post("http://localhost:8088/room/1")
55+
client.post("http://localhost:12345/room/1")
4456
.body(whom)
4557
.send().unwrap();
4658
},

0 commit comments

Comments
 (0)