From 4a2287ee4645fc6b9defb1c233ff8f9862882fa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Tue, 31 Dec 2019 03:59:03 +0100 Subject: [PATCH] readme improvements --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c215d3a..f3eca94 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,13 @@ The implementation is generic to support any type as session data: a custom stru `HashMap`, or perhaps `serde_json::Value`. You're free to choose. The session expiry time is configurable through the Fairing. When a session expires, -the data associated with it is dropped. +the data associated with it is dropped. All expired sessions may be cleared by calling `.remove_expired()` +on the `SessionStore`, which is be obtained in routes as `State`, or from a +session instance by calling `.get_store()`. -## Basic example +The session cookie is currently hardcoded to "SESSID" and contains 16 random characters. + +## Basic Example This simple example uses u64 as the session variable; note that it can be a struct, map, or anything else, it just needs to implement `Send + Sync + Default`. @@ -44,9 +48,9 @@ fn index(session: Session) -> String { } ``` -## Extending by a trait +## Extending Session by a Trait -The `tap` method is powerful, but sometimes you may wish for something more convenient. +The `.tap()` method is powerful, but sometimes you may wish for something more convenient. Here is an example of using a custom trait and the `json_dotpath` crate to implement a polymorphic store based on serde serialization: