-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
I've just looked through the examples and documentation how to write a good handlers. And all over the place, the it uses .unwrap on Results which could also be Err. This leads to panics in rust - basically what Cloudflare took down last week.
Here are a couple of unsafe unwraps:
hyper/examples/service_struct_impl.rs
Line 54 in be18a92
Ok(Response::builder().body(Full::new(Bytes::from(s))).unwrap()) Line 64 in be18a92
.unwrap() Line 32 in be18a92
.unwrap(); Line 103 in be18a92
.unwrap();
And when I would now remove these unwraps+ the Ok and directly try to return the Result... it would now work because these Response builders are using as Error type hyper::http::Errors and all the examples are build around hyper::Error.
The examples are basically only showing us how to not to write good servers.