Actix 2.0 如何从 Request 获取 Cookie

How to get Cookie from Request in Actix 2.0

我想从请求中获取 cookie 的值。我发现在 Actix 0.x.x 中,cookie 的值可以通过调用

获得
fn get_cookie(req: HttpRequest) {
    let cookie = req.cookie("name") <-- Here

    return HttpResponse::Ok()
        .body(
            format!("{}", cookie);
        )
}

我对 Rust 和 Actix 很陌生。目前我正在从声明的函数中解析它,该函数获取 HttpRequest.headers() 的字符串。我不确定是否有像 Actix 0.x.x.

那样直接获取 cookie 的方法
pub fn get_cookie(req: HttpRequest, name: &str) -> String {
    let cookie: Vec<&str> = req
        .headers()
        .get("cookie")
        .unwrap()
        .to_str()
        .unwrap()
        .split("&")
        .collect();

    let auth_token: Vec<&str> = cookie
        .into_iter()
        .filter(|each| {
            let body: Vec<&str> = each.split("=").collect();

            body[0] == name
        })
        .collect();

    let cookie_part: Vec<&str> = auth_token[0].split("=").collect();

    cookie_part[1].to_owned() 
}

HttpRequest implements HttpMessage which has a cookie method 就这么叫吗?