• Stars
    star
    115
  • Rank 305,916 (Top 7 %)
  • Language
    Rust
  • License
    MIT License
  • Created about 3 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A tower (axum) cookies manager

License Crates.io Docs.rs

tower-cookies

A cookie manager middleware built on top of tower.

Example

With axum:

use axum::{routing::get, Router};
use std::net::SocketAddr;
use tower_cookies::{Cookie, CookieManagerLayer, Cookies};

#[tokio::main]
async fn main() {
    let app = Router::new()
        .route("/", get(handler))
        .layer(CookieManagerLayer::new());

    let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
    let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
    axum::serve(listener, app.into_make_service())
        .await
        .unwrap();
}

async fn handler(cookies: Cookies) -> &'static str {
    cookies.add(Cookie::new("hello_world", "hello_world"));

    "Check your cookies."
}

A complete CRUD cookie example in examples/counter.rs

Safety

This crate uses #![forbid(unsafe_code)] to ensure everything is implemented in 100% safe Rust.

Contributing

We appreciate all kinds of contributions, thank you!

Note on README

Most of the readme is automatically copied from the crate documentation by cargo-sync-readme. This way the readme is always in sync with the docs and examples are tested.

So if you find a part of the readme you'd like to change between <!-- cargo-sync-readme start --> and <!-- cargo-sync-readme end --> markers, don't edit README.md directly, but rather change the documentation on top of src/lib.rs and then synchronize the readme with:

cargo sync-readme

(make sure the cargo command is installed):

cargo install cargo-sync-readme

If you have rusty-hook installed the changes will apply automatically on commit.

License

This project is licensed under the MIT license.

More Repositories

1

rust-derive-macro-guide

Simple derive macros in Rust
Rust
180
star
2

aiohttp-login

Registration and authorization (including social) for aiohttp apps.
Python
51
star
3

axum-client-ip

A client IP address extractor for Axum
Rust
40
star
4

step-machine

Run your Rust CLI programs as state machines with persistence and recovery abilities
Rust
34
star
5

sapper-google-analytics

Google Analytics for Sapper (Svelte)
HTML
34
star
6

tower-request-id

A tower (hyper, axum, warp) service to add an unique id for every request
Rust
25
star
7

sapper-page-loading-bar

Page preloader for Sapper
HTML
23
star
8

pg_task

FSM-based Resumable Postgres tasks
Rust
19
star
9

aiohttp_skeleton

Skeleton for aiohttp site
Python
19
star
10

aiolog

Asynchronous handlers for standard python logging library
Python
17
star
11

async-django-user

Using django user with async frameworks like aiohttp, starlette, etc.
Python
11
star
12

japronto-extra

Python
11
star
13

async_django_session

Django-compatible session for async frameworks
Python
10
star
14

django-route-decorator

A flask-style `route` decorator for django views
Python
10
star
15

habr-modern-tornado

Python
9
star
16

asjson

Json dumps and loads with datetime and date support
Python
7
star
17

sqlite_dbm

Dict-style DBM based on sqlite3
Python
7
star
18

mongo

simple pymongo object wrapper
Python
7
star
19

tagged-channels

Tag channels and message using tags (WebSockets, SSE users management)
Rust
6
star
20

django-raw-api

Async-friendly straightforward Django API helpers
Python
5
star
21

aiorest-angular-template

python asyncio + aiorest + jinja2 + angular.js + gulp.js + bower.js + nginx
Python
4
star
22

unidbm

Dict-style key value wrapper around some embeded databases
Python
3
star
23

action-loop

Offline-first web app with Hoodie & React
JavaScript
3
star
24

embed-file

Embeds files content into the binary in release mode, but loads it from the fs in debug
Rust
3
star
25

single_access

Single access to run a python script
Python
2
star
26

sqlx_error

A wrapper around `sqlx::Error` to provide error path and additional context
Rust
2
star
27

derby-yamlpages

Flexible flatpages for derby.js based on yaml syntax
JavaScript
2
star
28

django_skeleton

Python
2
star
29

csv-line

Fast deserializer for a single csv line
Rust
2
star
30

server-setup

Shell
2
star
31

flatpage

A simple file system based markdown flat page
Rust
2
star
32

aiohttp_tools

A set of little tools for aiohttp-based sites.
Python
2
star
33

express-url4

Reversing routes for express and browser. Like a Rails or Flask url_for method.
JavaScript
1
star
34

serde-csv-extra

Csv-related serde addons
Rust
1
star
35

webassets-ng-annotate

ng-annotate filter for webassets
Python
1
star
36

flask-peewee-skeleton

Python
1
star
37

aws-resource-id

Copy-able stack-only AWS Resource IDs
Rust
1
star
38

wheezy-setup

Shell
1
star
39

csvfile

A simple way of working with csv files.
Python
1
star
40

jsondict

Dict with json file saving / restoring support
Python
1
star
41

colt-faq

1
star
42

notes

Personal notes
Rust
1
star
43

lesync

Http helpers for django-channels
Python
1
star
44

firefox_jar

Python
1
star
45

lz4_flex_py

A Python wrapper for lz4_flex Rust crate
Rust
1
star
46

csv-partial-cache

Csv index with partially cached columns
Rust
1
star
47

seq-timer

A simple timer for sequential events
Rust
1
star