How can I get HttpRequest Cookie in actix-web 1.0.0-beta

#1

I got the error below. how can i get request cookie.

fn handler(
    req: HttpRequest,
    query: web::Query<HashMap<String, String>>
) -> impl Future<Item = HttpResponse, Error = AWError> {

    let _ = req.cookie("key-name");
error[E0599]: no method named `cookie` found for type `actix_web::HttpRequest` in the current scope
  --> src/main.rs:61:17
   |
61 |     let _ = req.cookie("key-name");

Cargo.toml


[dependencies]
actix-rt = "0.2.2"
actix-web = "1.0.0-beta.5"                                                                                                                                                                                      
actix-http = "0.1.0"
futures = "0.1"
time = "0.1"
env_logger = "0.5"
uuid = { version = "0.7", features = ["serde", "v4"] }

serde = "1.0"
serde_json = "1.0"
serde_derive = "1.0"
#2

use actix_web::HttpMessage;

#3

Thank you for your reply.

How can i handle HttpMessage?

fn handler(
    req: HttpRequest,
    msg: HttpMessage,
    query: web::Query<HashMap<String, String>>
) -> impl Future<Item = HttpResponse, Error = AWError> {

    let _ = msg.cookie("X-UUID");

error[E0191]: the value of the associated type `Stream` (from the trait `actix_web::HttpMessage`) must be specified
  --> src/main.rs:58:10
   |
58 |     msg: actix_web::HttpMessage,
   |          ^^^^^^^^^^^^^^^^^^^^^^ associated type `Stream` must be specified
#4

Like the error says, it is a trait. HttpRequest implements the trait. The compiler needs the use adding so it has knowledge.

#5

Thank you. I understand clearly.