1
0
mirror of https://github.com/actix/examples synced 2024-11-27 16:02:57 +01:00

make the code neater (#49)

This commit is contained in:
Madao 2018-09-28 13:35:13 +08:00 committed by Douman
parent 87f89b54f0
commit 3c5d53416b

View File

@ -34,11 +34,11 @@ fn welcome(req: &HttpRequest) -> Result<HttpResponse> {
if let Some(count) = req.session().get::<i32>("counter")? {
println!("SESSION value: {}", count);
counter = count + 1;
req.session().set("counter", counter)?;
} else {
req.session().set("counter", counter)?;
}
// set counter to session
req.session().set("counter", counter)?;
// response
Ok(HttpResponse::build(StatusCode::OK)
.content_type("text/html; charset=utf-8")