Skip to content

Commit 0ca64f8

Browse files
committed
Update client.rs
・not use unwrap()
1 parent bf87cd7 commit 0ca64f8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/client.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ impl HttpClient {
2323
/// ```
2424
pub fn new(channel_token: &str) -> HttpClient {
2525
let mut headers = HeaderMap::new();
26-
headers.insert(
27-
AUTHORIZATION,
28-
format!("Bearer {}", channel_token).parse().unwrap(),
29-
);
26+
if let Ok(v) = format!("Bearer {}", channel_token).parse::<String>() {
27+
if let Ok(header_value) = HeaderValue::from_str(&v) {
28+
headers.insert(AUTHORIZATION, header_value);
29+
}
30+
}
3031
headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
3132
HttpClient {
3233
client: Client::new(),

0 commit comments

Comments
 (0)