Cookiebox
A type safe cookie management crate for the Actix Web framework.
Cookiebox provides a type safe and flexible approach to managing cookies in Actix web based applications. It allows you to define, configure, and manage cookies with minimal boilerplate.
Features
- This crate uses biscotti under the hood, which inherit most of it's features.
- Offers the ability to configure settings on a per cookie basis.
- Enforces type definitions for deserializing cookie values upon retrieval.
- Allows customization of both the data type and data serialization.
- Provides a straightforward and type safe interface for managing cookies.
Usage
To start using the cookiebox in your web application, you must register [CookieMiddleware] in your App.
use ;
use ;
async
Define your desired cookie types with customizable configurations.
use HttpMessage;
use ;
use ;
use ;
use json;
// Define a cookie type
;
// IncomingConfig gives the cookie type get and get_all cookies with similar name
// You may opt out if don't want read cookie data
// OutgoingConfig gives the cookie type insert and remove cookies
// You may opt out if don't want insert or remove a cookie
// Once defined, you need to add these cookies in a collection struct and use derive macro to implement FromRequest
// Note: The macro only allows struct with either a single unnamed field or multiple named fields
;
Now, your cookies can be accessed in request handlers by using CookieCollection as a parameter.
If you would like to see an example, click here.
Important Notice
Versions 0.1.0 and 0.2.0 of this crate are deprecated due to missing key features.
Please use version 0.2.1 or later for a fully functional implementation.
Upgrade by updating your Cargo.toml:
[]
= "0.2.1"