Statically track the status of a Response by using a Phantom Type
Introduces two Phantom Types, Fresh and Streaming, which indicate the status of a Response. Response::start translates an Response<Fresh> into a Response<Streaming> by writing the StatusCode and Headers. Response<Fresh> allows modification of Headers and StatusCode, but does not allow writing to the body. Response<Streaming> has the opposite privileges.
This commit is contained in:
@@ -36,8 +36,13 @@ impl Handler for Echo {
|
||||
},
|
||||
(&Post, "/echo") => (), // fall through, fighting mutable borrows
|
||||
_ => {
|
||||
<<<<<<< Updated upstream
|
||||
res.status = hyper::status::NotFound;
|
||||
try_continue!(res.end());
|
||||
=======
|
||||
*res.status_mut() = hyper::status::NotFound;
|
||||
try_continue!(res.start().and_then(|res| res.end()));
|
||||
>>>>>>> Stashed changes
|
||||
continue;
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user