Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

session Build Status

Sessioning middleware for the Iron web framework.

Example

// Echo the sessioned count to the client
fn get_count(req: &mut Request, res: &mut Response) -> Status {
    // Retrieve our session from the store
    let session = req.alloy.find_mut::<Session<SocketAddr, u32>>().unwrap();
    // Store or increase the sessioned count
    let count = session.upsert(1u32, |v: &mut u32| { *v = *v + 1; } );

    println!("{} hits from\t{}", count, req.remote_addr.unwrap())
    let _ = res.serve(::http::status::Ok, format!("Sessioned count: {}", count).as_slice());

    Continue
}

fn main() {
    let mut server: Server = Iron::new();
    server.chain.link(Sessions::new(id_from_socket_addr, HashSessionStore::<id_type, u32>::new()));
    server.chain.link(FromFn::new(get_count));
    server.listen(Ipv4Addr(127, 0, 0, 1), 3000);
}

fn id_generator(req: &Request) -> id_type { ... }

Overview

session is a part of Iron's core bundle.

  • Includes an implemented HashMap-based session store
  • Key sessions based on your own id generating function
  • Store and retrieve data to/from keyed sessions

Installation

If you're using a Cargo.toml to manage dependencies, just add session to the toml:

[dependencies.session]

git = "https://github.com/iron/session.git"

Otherwise, cargo build, and the rlib will be in your target directory.

Along with the online documentation, you can build a local copy with cargo doc.

Get Help

One of us (@reem, @zzmp, @theptrk, @mcreinhard) is usually on #iron on the mozilla irc. Come say hi and ask any questions you might have. We are also usually on #rust and #rust-webdev.

About

Sessioning middleware for the iron web framework.

Resources

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages