MCPcopy Create free account
hub / github.com/actix/examples / index

Function index

auth/cookie-session/src/main.rs:19–33  ·  view source on GitHub ↗

simple index handler with session

(session: Session, req: HttpRequest)

Source from the content-addressed store, hash-verified

17
18/// simple index handler with session
19async fn index(session: Session, req: HttpRequest) -> Result<&'static str> {
20 log::info!("{req:?}");
21
22 // RequestSession trait is used for session access
23 let mut counter = 1;
24 if let Some(count) = session.get::<i32>("counter")? {
25 log::info!("SESSION value: {count}");
26 counter = count + 1;
27 session.insert("counter", counter)?;
28 } else {
29 session.insert("counter", counter)?;
30 }
31
32 Ok("welcome!")
33}
34
35#[actix_web::main]
36async fn main() -> std::io::Result<()> {

Callers

nothing calls this directly

Calls 1

insertMethod · 0.80

Tested by

no test coverage detected