Skip to content

Commit 032528f

Browse files
committed
Use maps.
1 parent d9bad85 commit 032528f

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

src/http/request.rs

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,17 @@ pub fn try_from_incoming_request(
6363

6464
let method = from_wasi_method(incoming.method())
6565
.map_err(|_| WasiHttpErrorCode::HttpRequestMethodInvalid)?;
66-
let scheme = match incoming.scheme() {
67-
Some(scheme) => Some(
68-
from_wasi_scheme(scheme).expect("TODO: what shall we do with an invalid uri here?"),
69-
),
70-
None => None,
71-
};
72-
let authority = match incoming.authority() {
73-
Some(authority) => Some(
74-
Authority::from_maybe_shared(authority)
75-
.expect("TODO: what shall we do with an invalid uri authority here?"),
76-
),
77-
None => None,
78-
};
79-
let path_and_query = match incoming.path_with_query() {
80-
Some(path_and_query) => Some(
81-
PathAndQuery::from_maybe_shared(path_and_query)
82-
.expect("TODO: what shall we do with an invalid uri path-and-query here?"),
83-
),
84-
None => None,
85-
};
66+
let scheme = incoming.scheme().map(|scheme| {
67+
from_wasi_scheme(scheme).expect("TODO: what shall we do with an invalid uri here?")
68+
});
69+
let authority = incoming.authority().map(|authority| {
70+
Authority::from_maybe_shared(authority)
71+
.expect("TODO: what shall we do with an invalid uri authority here?")
72+
});
73+
let path_and_query = incoming.path_with_query().map(|path_and_query| {
74+
PathAndQuery::from_maybe_shared(path_and_query)
75+
.expect("TODO: what shall we do with an invalid uri path-and-query here?")
76+
});
8677

8778
// TODO: What's the right error code to use for invalid headers?
8879
let kind = BodyKind::from_headers(&headers)

0 commit comments

Comments
 (0)