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:
parent
87f89b54f0
commit
3c5d53416b
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user