Cookiebox
A type safe cookie management crate for the Actix Web framework.
Cookiebox provides a robust, 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.
- Supports custom configuration settings per cookie
- Define specific types for deserializing cookie values during retrieval
- Customize data type and serialization method for each cookie.
- A Simple and type safe interface for retrieving, adding, removing cookies.
Usage
To start using the cookiebox crate in your web application you must register [CookieMiddleware] in your App.
use ;
use ;
async
Now, define the desired typed cookies with custom configuration
use HttpMessage;
use ;
use ;
use ;
use json;
// Define you cookie type struct
;
// IncomingConfig give the cookie type get and get_all cookie with similar name
// You may opt out if don't want read cookie data
// OutgoingConfig give the cookie type insert and remove cookie
// 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 the request handlers using teh CookieCollection as a parameter