Announcing tower-sessions 0.1.0

78 points maxcountryman

Hi folks,

A few days ago I reached out for feedback regarding a potential replacement for axum-sessions in the form of tower-sessions. (Reasons for this are discussed over there.)

Both crates provide HTTP sessions (key-value pairs associated with a site visitor) for tower and axum.

After that initial discussion (thank you to the folks that provided their thoughts) I've published the first release of tower-sessions.

Here's the overview, taken from the README:

  • Pluggable Storage Backends: Arbitrary storage backends are implemented with the SessionStore trait, fully decoupling sessions from their storage.
  • An axum Extractor for Session: Applications built with axum
    can use Session as an extractor directly in their handlers. This makes using sessions as easy as including Session in your handler.
  • Common Backends Out-of-the-Box: RedisStore and SQLx (SqliteStore, PostgresStore, MySqlStore) stores are available via their respective feature flags.
  • Simple Key-Value Interface: Sessions offer a key-value interface that supports native Rust types. So long as these types are Serialize and can be converted to JSON, it's straightforward to insert, get, and remove any value.
  • Strongly-Typed Sessions: Strong typing guarantees are easy to layer on top of this foundational key-value interface.

Also checkout the docs for a more detailed description of the design and how to go about using it.

My intent is to continue to iterate on the crate and migrate folks using axum-sessions to it.