mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-27 17:22:57 +01:00
Deploying to gh-pages from @ actix/actix-extras@4adc9f8884 🚀
This commit is contained in:
parent
da0a9406d3
commit
403e56a632
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,4 +1,4 @@
|
|||||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Session management for Actix Web."><title>actix_session - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-dd39b87e5fcfba68.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.81.0-nightly (f21554f7f 2024-06-08)" data-channel="nightly" data-search-js="search-9d4fa2dd5e5a7e17.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-118b08c4c78b968e.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-df360f571f6edeae.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="logo"></a><h2><a href="../actix_session/index.html">actix_session</a><span class="version">0.9.0</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section><ul class="block"><li><a href="#modules">Modules</a></li><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#traits">Traits</a></li></ul></section></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <a class="mod" href="#">actix_session</a><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><span class="out-of-band"><a class="src" href="../src/actix_session/lib.rs.html#1-740">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>−</span>]</button></span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Session management for Actix Web.</p>
|
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Session management for Actix Web."><title>actix_session - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-dd39b87e5fcfba68.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="actix_session" data-themes="" data-resource-suffix="" data-rustdoc-version="1.81.0-nightly (f21554f7f 2024-06-08)" data-channel="nightly" data-search-js="search-9d4fa2dd5e5a7e17.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-118b08c4c78b968e.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-df360f571f6edeae.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../actix_session/index.html"><img src="https://actix.rs/img/logo.png" alt="logo"></a><h2><a href="../actix_session/index.html">actix_session</a><span class="version">0.9.0</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section><ul class="block"><li><a href="#modules">Modules</a></li><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#traits">Traits</a></li></ul></section></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <a class="mod" href="#">actix_session</a><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><span class="out-of-band"><a class="src" href="../src/actix_session/lib.rs.html#1-738">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>−</span>]</button></span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Session management for Actix Web.</p>
|
||||||
<p>The HTTP protocol, at a first glance, is stateless: the client sends a request, the server
|
<p>The HTTP protocol, at a first glance, is stateless: the client sends a request, the server
|
||||||
parses its content, performs some processing and returns a response. The outcome is only
|
parses its content, performs some processing and returns a response. The outcome is only
|
||||||
influenced by the provided inputs (i.e. the request content) and whatever state the server
|
influenced by the provided inputs (i.e. the request content) and whatever state the server
|
||||||
@ -97,13 +97,13 @@ the <code>redis-session</code> feature flag.</p>
|
|||||||
# ...
|
# ...
|
||||||
actix-session = { version = "...", features = ["redis-session"] }
|
actix-session = { version = "...", features = ["redis-session"] }
|
||||||
</code></pre></div>
|
</code></pre></div>
|
||||||
<p>Add the <code>redis-session-native-tls</code> feature flag if you want to connect to Redis using a secured
|
<p>Add the <code>redis-session-native-tls</code> feature flag if you want to connect to Redis using a secure
|
||||||
connection (via the <code>native-tls</code> crate):</p>
|
connection (via the <code>native-tls</code> crate):</p>
|
||||||
<div class="example-wrap"><pre class="language-toml"><code>[dependencies]
|
<div class="example-wrap"><pre class="language-toml"><code>[dependencies]
|
||||||
# ...
|
# ...
|
||||||
actix-session = { version = "...", features = ["redis-session-native-tls"] }
|
actix-session = { version = "...", features = ["redis-session-native-tls"] }
|
||||||
</code></pre></div>
|
</code></pre></div>
|
||||||
<p>If you instead prefer depending on <code>rustls</code>, use the <code>redis-session-rustls</code> feature flag:</p>
|
<p>If you, instead, prefer depending on <code>rustls</code>, use the <code>redis-session-rustls</code> feature flag:</p>
|
||||||
<div class="example-wrap"><pre class="language-toml"><code>[dependencies]
|
<div class="example-wrap"><pre class="language-toml"><code>[dependencies]
|
||||||
# ...
|
# ...
|
||||||
actix-session = { version = "...", features = ["redis-session-rustls"] }
|
actix-session = { version = "...", features = ["redis-session-rustls"] }
|
||||||
|
@ -1 +1 @@
|
|||||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Documentation for Rustdoc"><title>Help</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="./static.files/${f}">`).join(""))</script><link rel="stylesheet" href="./static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="./static.files/rustdoc-dd39b87e5fcfba68.css"><meta name="rustdoc-vars" data-root-path="./" data-static-root-path="./static.files/" data-current-crate="actix_limitation" data-themes="" data-resource-suffix="" data-rustdoc-version="1.81.0-nightly (f21554f7f 2024-06-08)" data-channel="nightly" data-search-js="search-9d4fa2dd5e5a7e17.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="./static.files/storage-118b08c4c78b968e.js"></script><script defer src="./static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="./static.files/noscript-df360f571f6edeae.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc mod sys"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="./index.html"><img class="rust-logo" src="./static.files/rust-logo-151179464ae7ed46.svg" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="./index.html"><img class="rust-logo" src="./static.files/rust-logo-151179464ae7ed46.svg" alt="logo"></a><h2><a href="./index.html">Rustdoc</a><span class="version">1.81.0-nightly</span></h2></div><div class="version">(f21554f7f 2024-06-08)</div><h2 class="location">Help</h2><div class="sidebar-elems"></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Rustdoc help</h1><span class="out-of-band"><a id="back" href="javascript:void(0)" onclick="history.back();">Back</a></span></div><noscript><section><p>You need to enable JavaScript to use keyboard commands or search.</p><p>For more information, browse the <a href="https://doc.rust-lang.org/rustdoc/">rustdoc handbook</a>.</p></section></noscript></section></div></main></body></html>
|
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Documentation for Rustdoc"><title>Help</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="./static.files/${f}">`).join(""))</script><link rel="stylesheet" href="./static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="./static.files/rustdoc-dd39b87e5fcfba68.css"><meta name="rustdoc-vars" data-root-path="./" data-static-root-path="./static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.81.0-nightly (f21554f7f 2024-06-08)" data-channel="nightly" data-search-js="search-9d4fa2dd5e5a7e17.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="./static.files/storage-118b08c4c78b968e.js"></script><script defer src="./static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="./static.files/noscript-df360f571f6edeae.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc mod sys"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="./index.html"><img class="rust-logo" src="./static.files/rust-logo-151179464ae7ed46.svg" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="./index.html"><img class="rust-logo" src="./static.files/rust-logo-151179464ae7ed46.svg" alt="logo"></a><h2><a href="./index.html">Rustdoc</a><span class="version">1.81.0-nightly</span></h2></div><div class="version">(f21554f7f 2024-06-08)</div><h2 class="location">Help</h2><div class="sidebar-elems"></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Rustdoc help</h1><span class="out-of-band"><a id="back" href="javascript:void(0)" onclick="history.back();">Back</a></span></div><noscript><section><p>You need to enable JavaScript to use keyboard commands or search.</p><p>For more information, browse the <a href="https://doc.rust-lang.org/rustdoc/">rustdoc handbook</a>.</p></section></noscript></section></div></main></body></html>
|
@ -1 +1 @@
|
|||||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Settings of Rustdoc"><title>Settings</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="./static.files/${f}">`).join(""))</script><link rel="stylesheet" href="./static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="./static.files/rustdoc-dd39b87e5fcfba68.css"><meta name="rustdoc-vars" data-root-path="./" data-static-root-path="./static.files/" data-current-crate="actix_limitation" data-themes="" data-resource-suffix="" data-rustdoc-version="1.81.0-nightly (f21554f7f 2024-06-08)" data-channel="nightly" data-search-js="search-9d4fa2dd5e5a7e17.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="./static.files/storage-118b08c4c78b968e.js"></script><script defer src="./static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="./static.files/noscript-df360f571f6edeae.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc mod sys"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="./index.html"><img class="rust-logo" src="./static.files/rust-logo-151179464ae7ed46.svg" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="./index.html"><img class="rust-logo" src="./static.files/rust-logo-151179464ae7ed46.svg" alt="logo"></a><h2><a href="./index.html">Rustdoc</a><span class="version">1.81.0-nightly</span></h2></div><div class="version">(f21554f7f 2024-06-08)</div><h2 class="location">Settings</h2><div class="sidebar-elems"></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Rustdoc settings</h1><span class="out-of-band"><a id="back" href="javascript:void(0)" onclick="history.back();">Back</a></span></div><noscript><section>You need to enable JavaScript be able to update your settings.</section></noscript><script defer src="./static.files/settings-4313503d2e1961c2.js"></script></section></div></main></body></html>
|
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Settings of Rustdoc"><title>Settings</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="./static.files/${f}">`).join(""))</script><link rel="stylesheet" href="./static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="./static.files/rustdoc-dd39b87e5fcfba68.css"><meta name="rustdoc-vars" data-root-path="./" data-static-root-path="./static.files/" data-current-crate="actix_web_httpauth" data-themes="" data-resource-suffix="" data-rustdoc-version="1.81.0-nightly (f21554f7f 2024-06-08)" data-channel="nightly" data-search-js="search-9d4fa2dd5e5a7e17.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="./static.files/storage-118b08c4c78b968e.js"></script><script defer src="./static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="./static.files/noscript-df360f571f6edeae.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc mod sys"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="./index.html"><img class="rust-logo" src="./static.files/rust-logo-151179464ae7ed46.svg" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="./index.html"><img class="rust-logo" src="./static.files/rust-logo-151179464ae7ed46.svg" alt="logo"></a><h2><a href="./index.html">Rustdoc</a><span class="version">1.81.0-nightly</span></h2></div><div class="version">(f21554f7f 2024-06-08)</div><h2 class="location">Settings</h2><div class="sidebar-elems"></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Rustdoc settings</h1><span class="out-of-band"><a id="back" href="javascript:void(0)" onclick="history.back();">Back</a></span></div><noscript><section>You need to enable JavaScript be able to update your settings.</section></noscript><script defer src="./static.files/settings-4313503d2e1961c2.js"></script></section></div></main></body></html>
|
@ -736,149 +736,145 @@
|
|||||||
<a href="#736" id="736">736</a>
|
<a href="#736" id="736">736</a>
|
||||||
<a href="#737" id="737">737</a>
|
<a href="#737" id="737">737</a>
|
||||||
<a href="#738" id="738">738</a>
|
<a href="#738" id="738">738</a>
|
||||||
<a href="#739" id="739">739</a>
|
</pre></div><pre class="rust"><code><span class="doccomment">//! Session management for Actix Web.
|
||||||
<a href="#740" id="740">740</a>
|
//!
|
||||||
</pre></div><pre class="rust"><code><span class="doccomment">/*!
|
//! The HTTP protocol, at a first glance, is stateless: the client sends a request, the server
|
||||||
Session management for Actix Web.
|
//! parses its content, performs some processing and returns a response. The outcome is only
|
||||||
|
//! influenced by the provided inputs (i.e. the request content) and whatever state the server
|
||||||
The HTTP protocol, at a first glance, is stateless: the client sends a request, the server
|
//! queries while performing its processing.
|
||||||
parses its content, performs some processing and returns a response. The outcome is only
|
//!
|
||||||
influenced by the provided inputs (i.e. the request content) and whatever state the server
|
//! Stateless systems are easier to reason about, but they are not quite as powerful as we need them
|
||||||
queries while performing its processing.
|
//! to be - e.g. how do you authenticate a user? The user would be forced to authenticate **for
|
||||||
|
//! every single request**. That is, for example, how 'Basic' Authentication works. While it may
|
||||||
Stateless systems are easier to reason about, but they are not quite as powerful as we need them
|
//! work for a machine user (i.e. an API client), it is impractical for a person—you do not want a
|
||||||
to be - e.g. how do you authenticate a user? The user would be forced to authenticate **for
|
//! login prompt on every single page you navigate to!
|
||||||
every single request**. That is, for example, how 'Basic' Authentication works. While it may
|
//!
|
||||||
work for a machine user (i.e. an API client), it is impractical for a person—you do not want a
|
//! There is a solution - **sessions**. Using sessions the server can attach state to a set of
|
||||||
login prompt on every single page you navigate to!
|
//! requests coming from the same client. They are built on top of cookies - the server sets a
|
||||||
|
//! cookie in the HTTP response (`Set-Cookie` header), the client (e.g. the browser) will store the
|
||||||
There is a solution - **sessions**. Using sessions the server can attach state to a set of
|
//! cookie and play it back to the server when sending new requests (using the `Cookie` header).
|
||||||
requests coming from the same client. They are built on top of cookies - the server sets a
|
//!
|
||||||
cookie in the HTTP response (`Set-Cookie` header), the client (e.g. the browser) will store the
|
//! We refer to the cookie used for sessions as a **session cookie**. Its content is called
|
||||||
cookie and play it back to the server when sending new requests (using the `Cookie` header).
|
//! **session key** (or **session ID**), while the state attached to the session is referred to as
|
||||||
|
//! **session state**.
|
||||||
We refer to the cookie used for sessions as a **session cookie**. Its content is called
|
//!
|
||||||
**session key** (or **session ID**), while the state attached to the session is referred to as
|
//! `actix-session` provides an easy-to-use framework to manage sessions in applications built on
|
||||||
**session state**.
|
//! top of Actix Web. [`SessionMiddleware`] is the middleware underpinning the functionality
|
||||||
|
//! provided by `actix-session`; it takes care of all the session cookie handling and instructs the
|
||||||
`actix-session` provides an easy-to-use framework to manage sessions in applications built on
|
//! **storage backend** to create/delete/update the session state based on the operations performed
|
||||||
top of Actix Web. [`SessionMiddleware`] is the middleware underpinning the functionality
|
//! against the active [`Session`].
|
||||||
provided by `actix-session`; it takes care of all the session cookie handling and instructs the
|
//!
|
||||||
**storage backend** to create/delete/update the session state based on the operations performed
|
//! `actix-session` provides some built-in storage backends: ([`CookieSessionStore`],
|
||||||
against the active [`Session`].
|
//! [`RedisSessionStore`], and [`RedisActorSessionStore`]) - you can create a custom storage backend
|
||||||
|
//! by implementing the [`SessionStore`] trait.
|
||||||
`actix-session` provides some built-in storage backends: ([`CookieSessionStore`],
|
//!
|
||||||
[`RedisSessionStore`], and [`RedisActorSessionStore`]) - you can create a custom storage backend
|
//! Further reading on sessions:
|
||||||
by implementing the [`SessionStore`] trait.
|
//! - [RFC 6265](https://datatracker.ietf.org/doc/html/rfc6265);
|
||||||
|
//! - [OWASP's session management cheat-sheet](https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html).
|
||||||
Further reading on sessions:
|
//!
|
||||||
- [RFC 6265](https://datatracker.ietf.org/doc/html/rfc6265);
|
//! # Getting started
|
||||||
- [OWASP's session management cheat-sheet](https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html).
|
//! To start using sessions in your Actix Web application you must register [`SessionMiddleware`]
|
||||||
|
//! as a middleware on your `App`:
|
||||||
# Getting started
|
//!
|
||||||
To start using sessions in your Actix Web application you must register [`SessionMiddleware`]
|
//! ```no_run
|
||||||
as a middleware on your `App`:
|
//! use actix_web::{web, App, HttpServer, HttpResponse, Error};
|
||||||
|
//! use actix_session::{Session, SessionMiddleware, storage::RedisSessionStore};
|
||||||
```no_run
|
//! use actix_web::cookie::Key;
|
||||||
use actix_web::{web, App, HttpServer, HttpResponse, Error};
|
//!
|
||||||
use actix_session::{Session, SessionMiddleware, storage::RedisSessionStore};
|
//! #[actix_web::main]
|
||||||
use actix_web::cookie::Key;
|
//! async fn main() -> std::io::Result<()> {
|
||||||
|
//! // When using `Key::generate()` it is important to initialize outside of the
|
||||||
#[actix_web::main]
|
//! // `HttpServer::new` closure. When deployed the secret key should be read from a
|
||||||
async fn main() -> std::io::Result<()> {
|
//! // configuration file or environment variables.
|
||||||
// When using `Key::generate()` it is important to initialize outside of the
|
//! let secret_key = Key::generate();
|
||||||
// `HttpServer::new` closure. When deployed the secret key should be read from a
|
//!
|
||||||
// configuration file or environment variables.
|
//! let redis_store = RedisSessionStore::new("redis://127.0.0.1:6379")
|
||||||
let secret_key = Key::generate();
|
//! .await
|
||||||
|
//! .unwrap();
|
||||||
let redis_store = RedisSessionStore::new("redis://127.0.0.1:6379")
|
//!
|
||||||
.await
|
//! HttpServer::new(move ||
|
||||||
.unwrap();
|
//! App::new()
|
||||||
|
//! // Add session management to your application using Redis for session state storage
|
||||||
HttpServer::new(move ||
|
//! .wrap(
|
||||||
App::new()
|
//! SessionMiddleware::new(
|
||||||
// Add session management to your application using Redis for session state storage
|
//! redis_store.clone(),
|
||||||
.wrap(
|
//! secret_key.clone(),
|
||||||
SessionMiddleware::new(
|
//! )
|
||||||
redis_store.clone(),
|
//! )
|
||||||
secret_key.clone(),
|
//! .default_service(web::to(|| HttpResponse::Ok())))
|
||||||
)
|
//! .bind(("127.0.0.1", 8080))?
|
||||||
)
|
//! .run()
|
||||||
.default_service(web::to(|| HttpResponse::Ok())))
|
//! .await
|
||||||
.bind(("127.0.0.1", 8080))?
|
//! }
|
||||||
.run()
|
//! ```
|
||||||
.await
|
//!
|
||||||
}
|
//! The session state can be accessed and modified by your request handlers using the [`Session`]
|
||||||
```
|
//! extractor. Note that this doesn't work in the stream of a streaming response.
|
||||||
|
//!
|
||||||
The session state can be accessed and modified by your request handlers using the [`Session`]
|
//! ```no_run
|
||||||
extractor. Note that this doesn't work in the stream of a streaming response.
|
//! use actix_web::Error;
|
||||||
|
//! use actix_session::Session;
|
||||||
```no_run
|
//!
|
||||||
use actix_web::Error;
|
//! fn index(session: Session) -> Result<&'static str, Error> {
|
||||||
use actix_session::Session;
|
//! // access the session state
|
||||||
|
//! if let Some(count) = session.get::<i32>("counter")? {
|
||||||
fn index(session: Session) -> Result<&'static str, Error> {
|
//! println!("SESSION value: {}", count);
|
||||||
// access the session state
|
//! // modify the session state
|
||||||
if let Some(count) = session.get::<i32>("counter")? {
|
//! session.insert("counter", count + 1)?;
|
||||||
println!("SESSION value: {}", count);
|
//! } else {
|
||||||
// modify the session state
|
//! session.insert("counter", 1)?;
|
||||||
session.insert("counter", count + 1)?;
|
//! }
|
||||||
} else {
|
//!
|
||||||
session.insert("counter", 1)?;
|
//! Ok("Welcome!")
|
||||||
}
|
//! }
|
||||||
|
//! ```
|
||||||
Ok("Welcome!")
|
//!
|
||||||
}
|
//! # Choosing A Backend
|
||||||
```
|
//!
|
||||||
|
//! By default, `actix-session` does not provide any storage backend to retrieve and save the state
|
||||||
# Choosing A Backend
|
//! attached to your sessions. You can enable:
|
||||||
|
//!
|
||||||
By default, `actix-session` does not provide any storage backend to retrieve and save the state
|
//! - a purely cookie-based "backend", [`CookieSessionStore`], using the `cookie-session` feature
|
||||||
attached to your sessions. You can enable:
|
//! flag.
|
||||||
|
//!
|
||||||
- a purely cookie-based "backend", [`CookieSessionStore`], using the `cookie-session` feature
|
//! ```toml
|
||||||
flag.
|
//! [dependencies]
|
||||||
|
//! # ...
|
||||||
```toml
|
//! actix-session = { version = "...", features = ["cookie-session"] }
|
||||||
[dependencies]
|
//! ```
|
||||||
# ...
|
//!
|
||||||
actix-session = { version = "...", features = ["cookie-session"] }
|
//! - a Redis-based backend via [`redis-rs`](https://docs.rs/redis-rs), [`RedisSessionStore`], using
|
||||||
```
|
//! the `redis-session` feature flag.
|
||||||
|
//!
|
||||||
- a Redis-based backend via [`redis-rs`](https://docs.rs/redis-rs), [`RedisSessionStore`], using
|
//! ```toml
|
||||||
the `redis-session` feature flag.
|
//! [dependencies]
|
||||||
|
//! # ...
|
||||||
```toml
|
//! actix-session = { version = "...", features = ["redis-session"] }
|
||||||
[dependencies]
|
//! ```
|
||||||
# ...
|
//!
|
||||||
actix-session = { version = "...", features = ["redis-session"] }
|
//! Add the `redis-session-native-tls` feature flag if you want to connect to Redis using a secure
|
||||||
```
|
//! connection (via the `native-tls` crate):
|
||||||
|
//!
|
||||||
Add the `redis-session-native-tls` feature flag if you want to connect to Redis using a secured
|
//! ```toml
|
||||||
connection (via the `native-tls` crate):
|
//! [dependencies]
|
||||||
|
//! # ...
|
||||||
```toml
|
//! actix-session = { version = "...", features = ["redis-session-native-tls"] }
|
||||||
[dependencies]
|
//! ```
|
||||||
# ...
|
//!
|
||||||
actix-session = { version = "...", features = ["redis-session-native-tls"] }
|
//! If you, instead, prefer depending on `rustls`, use the `redis-session-rustls` feature flag:
|
||||||
```
|
//!
|
||||||
|
//! ```toml
|
||||||
If you instead prefer depending on `rustls`, use the `redis-session-rustls` feature flag:
|
//! [dependencies]
|
||||||
|
//! # ...
|
||||||
```toml
|
//! actix-session = { version = "...", features = ["redis-session-rustls"] }
|
||||||
[dependencies]
|
//! ```
|
||||||
# ...
|
//!
|
||||||
actix-session = { version = "...", features = ["redis-session-rustls"] }
|
//! You can implement your own session storage backend using the [`SessionStore`] trait.
|
||||||
```
|
//!
|
||||||
|
//! [`SessionStore`]: storage::SessionStore
|
||||||
You can implement your own session storage backend using the [`SessionStore`] trait.
|
//! [`CookieSessionStore`]: storage::CookieSessionStore
|
||||||
|
//! [`RedisSessionStore`]: storage::RedisSessionStore
|
||||||
[`SessionStore`]: storage::SessionStore
|
//! [`RedisActorSessionStore`]: storage::RedisActorSessionStore
|
||||||
[`CookieSessionStore`]: storage::CookieSessionStore
|
|
||||||
[`RedisSessionStore`]: storage::RedisSessionStore
|
|
||||||
[`RedisActorSessionStore`]: storage::RedisActorSessionStore
|
|
||||||
*/
|
|
||||||
|
|
||||||
</span><span class="attr">#![forbid(unsafe_code)]
|
</span><span class="attr">#![forbid(unsafe_code)]
|
||||||
#![deny(rust_2018_idioms, nonstandard_style)]
|
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
(function() {var implementors = {
|
(function() {var implementors = {
|
||||||
"actix_identity":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><<a class=\"struct\" href=\"actix_identity/error/struct.LostIdentityError.html\" title=\"struct actix_identity::error::LostIdentityError\">LostIdentityError</a>> for <a class=\"enum\" href=\"actix_identity/error/enum.GetIdentityError.html\" title=\"enum actix_identity::error::GetIdentityError\">GetIdentityError</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><<a class=\"struct\" href=\"actix_identity/error/struct.MissingIdentityError.html\" title=\"struct actix_identity::error::MissingIdentityError\">MissingIdentityError</a>> for <a class=\"enum\" href=\"actix_identity/error/enum.GetIdentityError.html\" title=\"enum actix_identity::error::GetIdentityError\">GetIdentityError</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><<a class=\"struct\" href=\"actix_identity/error/struct.SessionExpiryError.html\" title=\"struct actix_identity::error::SessionExpiryError\">SessionExpiryError</a>> for <a class=\"enum\" href=\"actix_identity/error/enum.GetIdentityError.html\" title=\"enum actix_identity::error::GetIdentityError\">GetIdentityError</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><SessionGetError> for <a class=\"enum\" href=\"actix_identity/error/enum.GetIdentityError.html\" title=\"enum actix_identity::error::GetIdentityError\">GetIdentityError</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><SessionInsertError> for <a class=\"struct\" href=\"actix_identity/error/struct.LoginError.html\" title=\"struct actix_identity::error::LoginError\">LoginError</a>"]],
|
"actix_identity":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><<a class=\"struct\" href=\"actix_identity/error/struct.LostIdentityError.html\" title=\"struct actix_identity::error::LostIdentityError\">LostIdentityError</a>> for <a class=\"enum\" href=\"actix_identity/error/enum.GetIdentityError.html\" title=\"enum actix_identity::error::GetIdentityError\">GetIdentityError</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><<a class=\"struct\" href=\"actix_identity/error/struct.MissingIdentityError.html\" title=\"struct actix_identity::error::MissingIdentityError\">MissingIdentityError</a>> for <a class=\"enum\" href=\"actix_identity/error/enum.GetIdentityError.html\" title=\"enum actix_identity::error::GetIdentityError\">GetIdentityError</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><<a class=\"struct\" href=\"actix_identity/error/struct.SessionExpiryError.html\" title=\"struct actix_identity::error::SessionExpiryError\">SessionExpiryError</a>> for <a class=\"enum\" href=\"actix_identity/error/enum.GetIdentityError.html\" title=\"enum actix_identity::error::GetIdentityError\">GetIdentityError</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><<a class=\"struct\" href=\"actix_session/session/struct.SessionGetError.html\" title=\"struct actix_session::session::SessionGetError\">SessionGetError</a>> for <a class=\"enum\" href=\"actix_identity/error/enum.GetIdentityError.html\" title=\"enum actix_identity::error::GetIdentityError\">GetIdentityError</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><<a class=\"struct\" href=\"actix_session/session/struct.SessionInsertError.html\" title=\"struct actix_session::session::SessionInsertError\">SessionInsertError</a>> for <a class=\"struct\" href=\"actix_identity/error/struct.LoginError.html\" title=\"struct actix_identity::error::LoginError\">LoginError</a>"]],
|
||||||
"actix_limitation":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><ComponentRange> for <a class=\"enum\" href=\"actix_limitation/enum.Error.html\" title=\"enum actix_limitation::Error\">Error</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><RedisError> for <a class=\"enum\" href=\"actix_limitation/enum.Error.html\" title=\"enum actix_limitation::Error\">Error</a>"]],
|
"actix_limitation":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><ComponentRange> for <a class=\"enum\" href=\"actix_limitation/enum.Error.html\" title=\"enum actix_limitation::Error\">Error</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><RedisError> for <a class=\"enum\" href=\"actix_limitation/enum.Error.html\" title=\"enum actix_limitation::Error\">Error</a>"]],
|
||||||
"actix_protobuf":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><<a class=\"struct\" href=\"https://docs.rs/prost/0.12.6/prost/error/struct.DecodeError.html\" title=\"struct prost::error::DecodeError\">DecodeError</a>> for <a class=\"enum\" href=\"actix_protobuf/enum.ProtoBufPayloadError.html\" title=\"enum actix_protobuf::ProtoBufPayloadError\">ProtoBufPayloadError</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><PayloadError> for <a class=\"enum\" href=\"actix_protobuf/enum.ProtoBufPayloadError.html\" title=\"enum actix_protobuf::ProtoBufPayloadError\">ProtoBufPayloadError</a>"]],
|
"actix_protobuf":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><<a class=\"struct\" href=\"https://docs.rs/prost/0.12.6/prost/error/struct.DecodeError.html\" title=\"struct prost::error::DecodeError\">DecodeError</a>> for <a class=\"enum\" href=\"actix_protobuf/enum.ProtoBufPayloadError.html\" title=\"enum actix_protobuf::ProtoBufPayloadError\">ProtoBufPayloadError</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><PayloadError> for <a class=\"enum\" href=\"actix_protobuf/enum.ProtoBufPayloadError.html\" title=\"enum actix_protobuf::ProtoBufPayloadError\">ProtoBufPayloadError</a>"]],
|
||||||
"actix_session":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><<a class=\"struct\" href=\"actix_session/config/struct.BrowserSession.html\" title=\"struct actix_session::config::BrowserSession\">BrowserSession</a>> for <a class=\"enum\" href=\"actix_session/config/enum.SessionLifecycle.html\" title=\"enum actix_session::config::SessionLifecycle\">SessionLifecycle</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><<a class=\"struct\" href=\"actix_session/config/struct.PersistentSession.html\" title=\"struct actix_session::config::PersistentSession\">PersistentSession</a>> for <a class=\"enum\" href=\"actix_session/config/enum.SessionLifecycle.html\" title=\"enum actix_session::config::SessionLifecycle\">SessionLifecycle</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><<a class=\"struct\" href=\"actix_session/storage/struct.SessionKey.html\" title=\"struct actix_session::storage::SessionKey\">SessionKey</a>> for <a class=\"struct\" href=\"https://doc.rust-lang.org/nightly/alloc/string/struct.String.html\" title=\"struct alloc::string::String\">String</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><<a class=\"struct\" href=\"https://docs.rs/anyhow/1.0.85/anyhow/struct.Error.html\" title=\"struct anyhow::Error\">Error</a>> for <a class=\"struct\" href=\"actix_session/struct.SessionGetError.html\" title=\"struct actix_session::SessionGetError\">SessionGetError</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><<a class=\"struct\" href=\"https://docs.rs/anyhow/1.0.85/anyhow/struct.Error.html\" title=\"struct anyhow::Error\">Error</a>> for <a class=\"struct\" href=\"actix_session/struct.SessionInsertError.html\" title=\"struct actix_session::SessionInsertError\">SessionInsertError</a>"]],
|
"actix_session":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><<a class=\"struct\" href=\"actix_session/config/struct.BrowserSession.html\" title=\"struct actix_session::config::BrowserSession\">BrowserSession</a>> for <a class=\"enum\" href=\"actix_session/config/enum.SessionLifecycle.html\" title=\"enum actix_session::config::SessionLifecycle\">SessionLifecycle</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><<a class=\"struct\" href=\"actix_session/config/struct.PersistentSession.html\" title=\"struct actix_session::config::PersistentSession\">PersistentSession</a>> for <a class=\"enum\" href=\"actix_session/config/enum.SessionLifecycle.html\" title=\"enum actix_session::config::SessionLifecycle\">SessionLifecycle</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><<a class=\"struct\" href=\"actix_session/storage/struct.SessionKey.html\" title=\"struct actix_session::storage::SessionKey\">SessionKey</a>> for <a class=\"struct\" href=\"https://doc.rust-lang.org/nightly/alloc/string/struct.String.html\" title=\"struct alloc::string::String\">String</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><<a class=\"struct\" href=\"https://docs.rs/anyhow/1.0.85/anyhow/struct.Error.html\" title=\"struct anyhow::Error\">Error</a>> for <a class=\"struct\" href=\"actix_session/struct.SessionGetError.html\" title=\"struct actix_session::SessionGetError\">SessionGetError</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/convert/trait.From.html\" title=\"trait core::convert::From\">From</a><<a class=\"struct\" href=\"https://docs.rs/anyhow/1.0.85/anyhow/struct.Error.html\" title=\"struct anyhow::Error\">Error</a>> for <a class=\"struct\" href=\"actix_session/struct.SessionInsertError.html\" title=\"struct actix_session::SessionInsertError\">SessionInsertError</a>"]],
|
||||||
|
Loading…
Reference in New Issue
Block a user