According to the documentation I could get mutable reference to the status
by calling status_mut()
. Unfortunately signature of the handler function, used to serve requests with hyper::Server contain immutable Response
, so the following code gives me an error:
pub fn handle_request(req: Request, res: Response<Fresh>){
let status: &mut StatusCode = res.status_mut();
}
error: cannot borrow immutable local variable `res` as mutable
Is there any way to set response status code in the request handler, used by hyper::server::Server?
UPD: Finally I have found the example. Right in the source code. =*)