mirror of
https://github.com/actix/actix-extras.git
synced 2025-08-30 11:08:08 +02:00
Deploying to gh-pages from @ 8741cd32cc
🚀
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
<!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="Extractor for HTTP Basic auth."><meta name="keywords" content="rust, rustlang, rust-lang, BasicAuth"><title>actix_web_httpauth::extractors::basic::BasicAuth - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings"></script><script src="../../../storage.js"></script><script src="../../../crates.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu" role="button">☰</div><a href='../../../actix_web_httpauth/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Struct BasicAuth</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.password">password</a><a href="#method.user_id">user_id</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AuthExtractor">AuthExtractor</a><a href="#impl-Clone">Clone</a><a href="#impl-Debug">Debug</a><a href="#impl-FromRequest">FromRequest</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-Same%3CT%3E">Same<T></a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a><a href="#impl-VZip%3CV%3E">VZip<V></a></div></div><p class="location"><a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">extractors</a>::<wbr><a href="index.html">basic</a></p><div id="sidebar-vars" data-name="BasicAuth" data-ty="struct" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../../brush.svg" width="18" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><button type="button" class="help-button">?</button>
|
||||
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">extractors</a>::<wbr><a href="index.html">basic</a>::<wbr><a class="struct" href="">BasicAuth</a></span><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../../src/actix_web_httpauth/extractors/basic.rs.html#92" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct BasicAuth(_);</pre></div><div class="docblock"><p>Extractor for HTTP Basic auth.</p>
|
||||
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="../../index.html">actix_web_httpauth</a>::<wbr><a href="../index.html">extractors</a>::<wbr><a href="index.html">basic</a>::<wbr><a class="struct" href="">BasicAuth</a><button id="copy-path" onclick="copy_path(this)">⎘</button></span><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../../src/actix_web_httpauth/extractors/basic.rs.html#92" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct BasicAuth(_);</pre></div><div class="docblock"><p>Extractor for HTTP Basic auth.</p>
|
||||
<h1 id="example" class="section-header"><a href="#example">Example</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="prelude-ty">Result</span>;
|
||||
<span class="kw">use</span> <span class="ident">actix_web_httpauth</span>::<span class="ident">extractors</span>::<span class="ident">basic</span>::<span class="ident">BasicAuth</span>;
|
||||
<span class="kw">use</span> <span class="ident">actix_web::Result</span>;
|
||||
<span class="kw">use</span> <span class="ident">actix_web_httpauth::extractors::basic::BasicAuth</span>;
|
||||
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">index</span>(<span class="ident">auth</span>: <span class="ident">BasicAuth</span>) <span class="op">-</span><span class="op">></span> <span class="ident">String</span> {
|
||||
<span class="macro">format</span><span class="macro">!</span>(<span class="string">"Hello, {}!"</span>, <span class="ident">auth</span>.<span class="ident">user_id</span>())
|
||||
<span class="macro">format!</span>(<span class="string">"Hello, {}!"</span>, <span class="ident">auth</span>.<span class="ident">user_id</span>())
|
||||
}</pre></div>
|
||||
<p>If authentication fails, this extractor fetches the <a href="./struct.Config.html"><code>Config</code></a> instance
|
||||
from the <a href="https://docs.rs/actix-web/1.0.0-beta.5/actix_web/struct.App.html#method.data">app data</a> in order to properly form the <code>WWW-Authenticate</code>
|
||||
@@ -16,16 +16,16 @@ response header.</p>
|
||||
<h2 id="example-1" class="section-header"><a href="#example-1">Example</a></h2>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">web</span>, <span class="ident">App</span>};
|
||||
<span class="kw">use</span> <span class="ident">actix_web_httpauth</span>::<span class="ident">extractors</span>::<span class="ident">basic</span>::{<span class="ident">BasicAuth</span>, <span class="ident">Config</span>};
|
||||
<span class="kw">use</span> <span class="ident">actix_web_httpauth::extractors::basic</span>::{<span class="ident">BasicAuth</span>, <span class="ident">Config</span>};
|
||||
|
||||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">index</span>(<span class="ident">auth</span>: <span class="ident">BasicAuth</span>) <span class="op">-</span><span class="op">></span> <span class="ident">String</span> {
|
||||
<span class="macro">format</span><span class="macro">!</span>(<span class="string">"Hello, {}!"</span>, <span class="ident">auth</span>.<span class="ident">user_id</span>())
|
||||
<span class="macro">format!</span>(<span class="string">"Hello, {}!"</span>, <span class="ident">auth</span>.<span class="ident">user_id</span>())
|
||||
}
|
||||
|
||||
<span class="kw">fn</span> <span class="ident">main</span>() {
|
||||
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">App</span>::<span class="ident">new</span>()
|
||||
.<span class="ident">data</span>(<span class="ident">Config</span>::<span class="ident">default</span>().<span class="ident">realm</span>(<span class="string">"Restricted area"</span>))
|
||||
.<span class="ident">service</span>(<span class="ident">web</span>::<span class="ident">resource</span>(<span class="string">"/index.html"</span>).<span class="ident">route</span>(<span class="ident">web</span>::<span class="ident">get</span>().<span class="ident">to</span>(<span class="ident">index</span>)));
|
||||
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">App::new</span>()
|
||||
.<span class="ident">data</span>(<span class="ident">Config::default</span>().<span class="ident">realm</span>(<span class="string">"Restricted area"</span>))
|
||||
.<span class="ident">service</span>(<span class="ident">web::resource</span>(<span class="string">"/index.html"</span>).<span class="ident">route</span>(<span class="ident">web::get</span>().<span class="ident">to</span>(<span class="ident">index</span>)));
|
||||
}</pre></div>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../../actix_web_httpauth/extractors/basic/struct.BasicAuth.html" title="struct actix_web_httpauth::extractors::basic::BasicAuth">BasicAuth</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../../src/actix_web_httpauth/extractors/basic.rs.html#94-104" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.user_id" class="method"><code>pub fn <a href="#method.user_id" class="fnname">user_id</a>(&self) -> &<a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a><'static, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>></code><a class="srclink" href="../../../src/actix_web_httpauth/extractors/basic.rs.html#96-98" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns client’s user-ID.</p>
|
||||
</div><h4 id="method.password" class="method"><code>pub fn <a href="#method.password" class="fnname">password</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a><'static, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>></code><a class="srclink" href="../../../src/actix_web_httpauth/extractors/basic.rs.html#101-103" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns client’s password.</p>
|
||||
|
Reference in New Issue
Block a user