Deploying to gh-pages from @ ac502b7c08 🚀

This commit is contained in:
realaravinth
2022-11-04 10:05:00 +00:00
parent 49538a56a4
commit 55a5f29113
941 changed files with 22322 additions and 30474 deletions

View File

@@ -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="Source of the Rust file `src/static_assets/static_files.rs`."><meta name="keywords" content="rust, rustlang, rust-lang"><title>static_files.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceCodePro-Semibold.ttf.woff2"><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="../../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../../storage.js"></script><script defer src="../../../source-script.js"></script><script defer src="../../../source-files.js"></script><script defer src="../../../main.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../../favicon.svg"></head><body class="rustdoc source"><!--[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">&#9776;</button><a class="sidebar-logo" href="../../../mcaptcha/index.html"><div class="logo-container"><img class="rust-logo" src="../../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../../mcaptcha/index.html"><div class="logo-container"><img class="rust-logo" src="../../../rust-logo.svg" alt="logo"></div></a></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../../mcaptcha/index.html"><img class="rust-logo" src="../../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="example-wrap"><pre class="line-numbers"><span id="1">1</span>
<!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="Source of the Rust file `src/static_assets/static_files.rs`."><meta name="keywords" content="rust, rustlang, rust-lang"><title>static_files.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../../../normalize.css"><link rel="stylesheet" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../../../ayu.css" disabled><link rel="stylesheet" href="../../../dark.css" disabled><link rel="stylesheet" href="../../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../../storage.js"></script><script defer src="../../../source-script.js"></script><script defer src="../../../source-files.js"></script><script defer src="../../../main.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../../favicon.svg"></head><body class="rustdoc source"><!--[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">&#9776;</button><a class="sidebar-logo" href="../../../mcaptcha/index.html"><div class="logo-container"><img class="rust-logo" src="../../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../../mcaptcha/index.html"><div class="logo-container"><img class="rust-logo" src="../../../rust-logo.svg" alt="logo"></div></a></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../../mcaptcha/index.html"><img class="rust-logo" src="../../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="example-wrap"><pre class="line-numbers"><span id="1">1</span>
<span id="2">2</span>
<span id="3">3</span>
<span id="4">4</span>
@@ -181,158 +181,158 @@
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;.
*/</span>
<span class="kw">use</span> <span class="ident">std::borrow::Cow</span>;
*/
</span><span class="kw">use </span>std::borrow::Cow;
<span class="kw">use</span> <span class="ident">actix_web::body::BoxBody</span>;
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">get</span>, <span class="ident">http::header</span>, <span class="ident">web</span>, <span class="ident">HttpResponse</span>, <span class="ident">Responder</span>};
<span class="kw">use</span> <span class="ident">log::debug</span>;
<span class="kw">use</span> <span class="ident">mime_guess::from_path</span>;
<span class="kw">use</span> <span class="ident">rust_embed::RustEmbed</span>;
<span class="kw">use </span>actix_web::body::BoxBody;
<span class="kw">use </span>actix_web::{get, http::header, web, HttpResponse, Responder};
<span class="kw">use </span>log::debug;
<span class="kw">use </span>mime_guess::from_path;
<span class="kw">use </span>rust_embed::RustEmbed;
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::CACHE_AGE</span>;
<span class="kw">use </span><span class="kw">crate</span>::CACHE_AGE;
<span class="kw">pub</span> <span class="kw">mod</span> <span class="ident">assets</span> {
<span class="kw">use</span> <span class="ident">lazy_static::lazy_static</span>;
<span class="kw">pub mod </span>assets {
<span class="kw">use </span>lazy_static::lazy_static;
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::FILES</span>;
<span class="kw">use </span><span class="kw">crate</span>::FILES;
<span class="kw">type</span> <span class="ident">Img</span> <span class="op">=</span> (<span class="kw-2">&amp;</span><span class="lifetime">&#39;static</span> <span class="ident">str</span>, <span class="kw-2">&amp;</span><span class="lifetime">&#39;static</span> <span class="ident">str</span>);
<span class="kw">type </span>Img = (<span class="kw-2">&amp;</span><span class="lifetime">&#39;static </span>str, <span class="kw-2">&amp;</span><span class="lifetime">&#39;static </span>str);
<span class="macro">lazy_static!</span> {
<span class="kw">pub</span> <span class="kw">static</span> <span class="kw-2">ref</span> <span class="ident">KEY</span>: <span class="ident">Img</span> <span class="op">=</span>
(<span class="ident">FILES</span>.<span class="ident">get</span>(<span class="string">&quot;./static/cache/img/svg/key.svg&quot;</span>).<span class="ident">unwrap</span>(), <span class="string">&quot;key&quot;</span>);
<span class="kw">pub</span> <span class="kw">static</span> <span class="kw-2">ref</span> <span class="ident">GITHUB</span>: <span class="ident">Img</span> <span class="op">=</span> (
<span class="ident">FILES</span>.<span class="ident">get</span>(<span class="string">&quot;./static/cache/img/svg/github.svg&quot;</span>).<span class="ident">unwrap</span>(),
<span class="string">&quot;Source code&quot;</span>
);
<span class="kw">pub</span> <span class="kw">static</span> <span class="kw-2">ref</span> <span class="ident">HOME</span>: <span class="ident">Img</span> <span class="op">=</span> (
<span class="ident">FILES</span>.<span class="ident">get</span>(<span class="string">&quot;./static/cache/img/svg/home.svg&quot;</span>).<span class="ident">unwrap</span>(),
<span class="string">&quot;Home&quot;</span>
);
<span class="kw">pub</span> <span class="kw">static</span> <span class="kw-2">ref</span> <span class="ident">SETTINGS_ICON</span>: <span class="ident">Img</span> <span class="op">=</span> (
<span class="ident">FILES</span>.<span class="ident">get</span>(<span class="string">&quot;./static/cache/img/svg/settings.svg&quot;</span>).<span class="ident">unwrap</span>(),
<span class="string">&quot;Settings&quot;</span>
);
<span class="kw">pub</span> <span class="kw">static</span> <span class="kw-2">ref</span> <span class="ident">CREDIT_CARD</span>: <span class="ident">Img</span> <span class="op">=</span> (
<span class="ident">FILES</span>.<span class="ident">get</span>(<span class="string">&quot;./static/cache/img/svg/credit-card.svg&quot;</span>).<span class="ident">unwrap</span>(),
<span class="string">&quot;Payment&quot;</span>
);
<span class="kw">pub</span> <span class="kw">static</span> <span class="kw-2">ref</span> <span class="ident">HELP_CIRCLE</span>: <span class="ident">Img</span> <span class="op">=</span> (
<span class="ident">FILES</span>.<span class="ident">get</span>(<span class="string">&quot;./static/cache/img/svg/help-circle.svg&quot;</span>).<span class="ident">unwrap</span>(),
<span class="string">&quot;Help&quot;</span>
);
<span class="kw">pub</span> <span class="kw">static</span> <span class="kw-2">ref</span> <span class="ident">MESSAGE</span>: <span class="ident">Img</span> <span class="op">=</span> (
<span class="ident">FILES</span>
.<span class="ident">get</span>(<span class="string">&quot;./static/cache/img/svg/message-square.svg&quot;</span>)
.<span class="ident">unwrap</span>(),
<span class="string">&quot;Message&quot;</span>
);
<span class="kw">pub</span> <span class="kw">static</span> <span class="kw-2">ref</span> <span class="ident">DOCS_ICON</span>: <span class="ident">Img</span> <span class="op">=</span> (
<span class="ident">FILES</span>.<span class="ident">get</span>(<span class="string">&quot;./static/cache/img/svg/file-text.svg&quot;</span>).<span class="ident">unwrap</span>(),
<span class="string">&quot;Documentation&quot;</span>
);
<span class="kw">pub</span> <span class="kw">static</span> <span class="kw-2">ref</span> <span class="ident">MCAPTCHA_TRANS_ICON</span>: <span class="ident">Img</span> <span class="op">=</span> (
<span class="ident">FILES</span>.<span class="ident">get</span>(<span class="string">&quot;./static/cache/img/icon-trans.png&quot;</span>).<span class="ident">unwrap</span>(),
<span class="string">&quot;Logo&quot;</span>
);
<span class="kw">pub</span> <span class="kw">static</span> <span class="kw-2">ref</span> <span class="ident">BAR_CHART</span>: <span class="ident">Img</span> <span class="op">=</span> (
<span class="ident">FILES</span>.<span class="ident">get</span>(<span class="string">&quot;./static/cache/img/svg/bar-chart.svg&quot;</span>).<span class="ident">unwrap</span>(),
<span class="string">&quot;Statistics&quot;</span>
);
<span class="macro">lazy_static! </span>{
<span class="kw">pub static </span><span class="kw-2">ref </span>KEY: Img =
(FILES.get(<span class="string">&quot;./static/cache/img/svg/key.svg&quot;</span>).unwrap(), <span class="string">&quot;key&quot;</span>);
<span class="kw">pub static </span><span class="kw-2">ref </span>GITHUB: Img = (
FILES.get(<span class="string">&quot;./static/cache/img/svg/github.svg&quot;</span>).unwrap(),
<span class="string">&quot;Source code&quot;
</span>);
<span class="kw">pub static </span><span class="kw-2">ref </span>HOME: Img = (
FILES.get(<span class="string">&quot;./static/cache/img/svg/home.svg&quot;</span>).unwrap(),
<span class="string">&quot;Home&quot;
</span>);
<span class="kw">pub static </span><span class="kw-2">ref </span>SETTINGS_ICON: Img = (
FILES.get(<span class="string">&quot;./static/cache/img/svg/settings.svg&quot;</span>).unwrap(),
<span class="string">&quot;Settings&quot;
</span>);
<span class="kw">pub static </span><span class="kw-2">ref </span>CREDIT_CARD: Img = (
FILES.get(<span class="string">&quot;./static/cache/img/svg/credit-card.svg&quot;</span>).unwrap(),
<span class="string">&quot;Payment&quot;
</span>);
<span class="kw">pub static </span><span class="kw-2">ref </span>HELP_CIRCLE: Img = (
FILES.get(<span class="string">&quot;./static/cache/img/svg/help-circle.svg&quot;</span>).unwrap(),
<span class="string">&quot;Help&quot;
</span>);
<span class="kw">pub static </span><span class="kw-2">ref </span>MESSAGE: Img = (
FILES
.get(<span class="string">&quot;./static/cache/img/svg/message-square.svg&quot;</span>)
.unwrap(),
<span class="string">&quot;Message&quot;
</span>);
<span class="kw">pub static </span><span class="kw-2">ref </span>DOCS_ICON: Img = (
FILES.get(<span class="string">&quot;./static/cache/img/svg/file-text.svg&quot;</span>).unwrap(),
<span class="string">&quot;Documentation&quot;
</span>);
<span class="kw">pub static </span><span class="kw-2">ref </span>MCAPTCHA_TRANS_ICON: Img = (
FILES.get(<span class="string">&quot;./static/cache/img/icon-trans.png&quot;</span>).unwrap(),
<span class="string">&quot;Logo&quot;
</span>);
<span class="kw">pub static </span><span class="kw-2">ref </span>BAR_CHART: Img = (
FILES.get(<span class="string">&quot;./static/cache/img/svg/bar-chart.svg&quot;</span>).unwrap(),
<span class="string">&quot;Statistics&quot;
</span>);
}
}
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">RustEmbed</span>)]</span>
<span class="attribute">#[<span class="ident">folder</span> <span class="op">=</span> <span class="string">&quot;assets/&quot;</span>]</span>
<span class="kw">struct</span> <span class="ident">Asset</span>;
<span class="attribute">#[derive(RustEmbed)]
#[folder = <span class="string">&quot;assets/&quot;</span>]
</span><span class="kw">struct </span>Asset;
<span class="kw">fn</span> <span class="ident">handle_assets</span>(<span class="ident">path</span>: <span class="kw-2">&amp;</span><span class="ident">str</span>) -&gt; <span class="ident">HttpResponse</span> {
<span class="kw">match</span> <span class="ident">Asset::get</span>(<span class="ident">path</span>) {
<span class="prelude-val">Some</span>(<span class="ident">content</span>) =&gt; {
<span class="kw">let</span> <span class="ident">body</span>: <span class="ident">BoxBody</span> <span class="op">=</span> <span class="kw">match</span> <span class="ident">content</span>.<span class="ident">data</span> {
<span class="ident">Cow::Borrowed</span>(<span class="ident">bytes</span>) =&gt; <span class="ident">BoxBody::new</span>(<span class="ident">bytes</span>),
<span class="ident">Cow::Owned</span>(<span class="ident">bytes</span>) =&gt; <span class="ident">BoxBody::new</span>(<span class="ident">bytes</span>),
<span class="kw">fn </span>handle_assets(path: <span class="kw-2">&amp;</span>str) -&gt; HttpResponse {
<span class="kw">match </span>Asset::get(path) {
<span class="prelude-val">Some</span>(content) =&gt; {
<span class="kw">let </span>body: BoxBody = <span class="kw">match </span>content.data {
Cow::Borrowed(bytes) =&gt; BoxBody::new(bytes),
Cow::Owned(bytes) =&gt; BoxBody::new(bytes),
};
<span class="ident">HttpResponse::Ok</span>()
.<span class="ident">insert_header</span>(<span class="ident">header::CacheControl</span>(<span class="macro">vec!</span>[
<span class="ident">header::CacheDirective::Public</span>,
<span class="ident">header::CacheDirective::Extension</span>(<span class="string">&quot;immutable&quot;</span>.<span class="ident">into</span>(), <span class="prelude-val">None</span>),
<span class="ident">header::CacheDirective::MaxAge</span>(<span class="ident">CACHE_AGE</span>),
HttpResponse::Ok()
.insert_header(header::CacheControl(<span class="macro">vec!</span>[
header::CacheDirective::Public,
header::CacheDirective::Extension(<span class="string">&quot;immutable&quot;</span>.into(), <span class="prelude-val">None</span>),
header::CacheDirective::MaxAge(CACHE_AGE),
]))
.<span class="ident">content_type</span>(<span class="ident">from_path</span>(<span class="ident">path</span>).<span class="ident">first_or_octet_stream</span>().<span class="ident">as_ref</span>())
.<span class="ident">body</span>(<span class="ident">body</span>)
.content_type(from_path(path).first_or_octet_stream().as_ref())
.body(body)
}
<span class="prelude-val">None</span> =&gt; <span class="ident">HttpResponse::NotFound</span>().<span class="ident">body</span>(<span class="string">&quot;404 Not Found&quot;</span>),
<span class="prelude-val">None </span>=&gt; HttpResponse::NotFound().body(<span class="string">&quot;404 Not Found&quot;</span>),
}
}
<span class="attribute">#[<span class="ident">get</span>(<span class="string">&quot;/assets/{_:.*}&quot;</span>)]</span>
<span class="kw">pub</span> <span class="kw">async</span> <span class="kw">fn</span> <span class="ident">static_files</span>(<span class="ident">path</span>: <span class="ident">web::Path</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span>) -&gt; <span class="kw">impl</span> <span class="ident">Responder</span> {
<span class="ident">handle_assets</span>(<span class="kw-2">&amp;</span><span class="ident">path</span>)
<span class="attribute">#[get(<span class="string">&quot;/assets/{_:.*}&quot;</span>)]
</span><span class="kw">pub async fn </span>static_files(path: web::Path&lt;String&gt;) -&gt; <span class="kw">impl </span>Responder {
handle_assets(<span class="kw-2">&amp;</span>path)
}
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">RustEmbed</span>)]</span>
<span class="attribute">#[<span class="ident">folder</span> <span class="op">=</span> <span class="string">&quot;static/favicons/&quot;</span>]</span>
<span class="kw">struct</span> <span class="ident">Favicons</span>;
<span class="attribute">#[derive(RustEmbed)]
#[folder = <span class="string">&quot;static/favicons/&quot;</span>]
</span><span class="kw">struct </span>Favicons;
<span class="kw">fn</span> <span class="ident">handle_favicons</span>(<span class="ident">path</span>: <span class="kw-2">&amp;</span><span class="ident">str</span>) -&gt; <span class="ident">HttpResponse</span> {
<span class="kw">match</span> <span class="ident">Favicons::get</span>(<span class="ident">path</span>) {
<span class="prelude-val">Some</span>(<span class="ident">content</span>) =&gt; {
<span class="kw">let</span> <span class="ident">body</span>: <span class="ident">BoxBody</span> <span class="op">=</span> <span class="kw">match</span> <span class="ident">content</span>.<span class="ident">data</span> {
<span class="ident">Cow::Borrowed</span>(<span class="ident">bytes</span>) =&gt; <span class="ident">BoxBody::new</span>(<span class="ident">bytes</span>),
<span class="ident">Cow::Owned</span>(<span class="ident">bytes</span>) =&gt; <span class="ident">BoxBody::new</span>(<span class="ident">bytes</span>),
<span class="kw">fn </span>handle_favicons(path: <span class="kw-2">&amp;</span>str) -&gt; HttpResponse {
<span class="kw">match </span>Favicons::get(path) {
<span class="prelude-val">Some</span>(content) =&gt; {
<span class="kw">let </span>body: BoxBody = <span class="kw">match </span>content.data {
Cow::Borrowed(bytes) =&gt; BoxBody::new(bytes),
Cow::Owned(bytes) =&gt; BoxBody::new(bytes),
};
<span class="ident">HttpResponse::Ok</span>()
.<span class="ident">insert_header</span>(<span class="ident">header::CacheControl</span>(<span class="macro">vec!</span>[
<span class="ident">header::CacheDirective::Public</span>,
<span class="ident">header::CacheDirective::Extension</span>(<span class="string">&quot;immutable&quot;</span>.<span class="ident">into</span>(), <span class="prelude-val">None</span>),
<span class="ident">header::CacheDirective::MaxAge</span>(<span class="ident">CACHE_AGE</span>),
HttpResponse::Ok()
.insert_header(header::CacheControl(<span class="macro">vec!</span>[
header::CacheDirective::Public,
header::CacheDirective::Extension(<span class="string">&quot;immutable&quot;</span>.into(), <span class="prelude-val">None</span>),
header::CacheDirective::MaxAge(CACHE_AGE),
]))
.<span class="ident">content_type</span>(<span class="ident">from_path</span>(<span class="ident">path</span>).<span class="ident">first_or_octet_stream</span>().<span class="ident">as_ref</span>())
.<span class="ident">body</span>(<span class="ident">body</span>)
.content_type(from_path(path).first_or_octet_stream().as_ref())
.body(body)
}
<span class="prelude-val">None</span> =&gt; <span class="ident">HttpResponse::NotFound</span>().<span class="ident">body</span>(<span class="string">&quot;404 Not Found&quot;</span>),
<span class="prelude-val">None </span>=&gt; HttpResponse::NotFound().body(<span class="string">&quot;404 Not Found&quot;</span>),
}
}
<span class="attribute">#[<span class="ident">get</span>(<span class="string">&quot;/{file}&quot;</span>)]</span>
<span class="kw">pub</span> <span class="kw">async</span> <span class="kw">fn</span> <span class="ident">favicons</span>(<span class="ident">path</span>: <span class="ident">web::Path</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span>) -&gt; <span class="kw">impl</span> <span class="ident">Responder</span> {
<span class="attribute">#[get(<span class="string">&quot;/{file}&quot;</span>)]
</span><span class="kw">pub async fn </span>favicons(path: web::Path&lt;String&gt;) -&gt; <span class="kw">impl </span>Responder {
<span class="macro">debug!</span>(<span class="string">&quot;searching favicons&quot;</span>);
<span class="ident">handle_favicons</span>(<span class="kw-2">&amp;</span><span class="ident">path</span>)
handle_favicons(<span class="kw-2">&amp;</span>path)
}
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">test</span>)]</span>
<span class="kw">mod</span> <span class="ident">tests</span> {
<span class="kw">use</span> <span class="ident">actix_web::http::StatusCode</span>;
<span class="kw">use</span> <span class="ident">actix_web::test</span>;
<span class="attribute">#[cfg(test)]
</span><span class="kw">mod </span>tests {
<span class="kw">use </span>actix_web::http::StatusCode;
<span class="kw">use </span>actix_web::test;
<span class="kw">use</span> <span class="kw">crate</span>::<span class="kw-2">*</span>;
<span class="kw">use crate</span>::<span class="kw-2">*</span>;
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">static_assets_work</span>() {
<span class="kw">let</span> <span class="ident">app</span> <span class="op">=</span> <span class="macro">get_app!</span>().<span class="kw">await</span>;
<span class="attribute">#[actix_rt::test]
</span><span class="kw">async fn </span>static_assets_work() {
<span class="kw">let </span>app = <span class="macro">get_app!</span>().<span class="kw">await</span>;
<span class="kw">let</span> <span class="ident">urls</span> <span class="op">=</span> [
<span class="kw-2">*</span><span class="ident"><span class="kw">crate</span>::JS</span>,
<span class="kw-2">*</span><span class="ident"><span class="kw">crate</span>::VERIFICATIN_WIDGET_JS</span>,
<span class="kw-2">*</span><span class="ident"><span class="kw">crate</span>::VERIFICATIN_WIDGET_CSS</span>,
<span class="ident"><span class="kw">crate</span>::FILES</span>
.<span class="ident">get</span>(<span class="string">&quot;./static/cache/img/icon-trans.png&quot;</span>)
.<span class="ident">unwrap</span>(),
<span class="kw">let </span>urls = [
<span class="kw-2">*</span><span class="kw">crate</span>::JS,
<span class="kw-2">*</span><span class="kw">crate</span>::VERIFICATIN_WIDGET_JS,
<span class="kw-2">*</span><span class="kw">crate</span>::VERIFICATIN_WIDGET_CSS,
<span class="kw">crate</span>::FILES
.get(<span class="string">&quot;./static/cache/img/icon-trans.png&quot;</span>)
.unwrap(),
<span class="string">&quot;/favicon.ico&quot;</span>,
];
<span class="kw">for</span> <span class="ident">u</span> <span class="kw">in</span> <span class="ident">urls</span>.<span class="ident">iter</span>() {
<span class="kw">for </span>u <span class="kw">in </span>urls.iter() {
<span class="macro">println!</span>(<span class="string">&quot;[*] Testing static asset at URL: {u}&quot;</span>);
<span class="kw">let</span> <span class="ident">resp</span> <span class="op">=</span>
<span class="ident">test::call_service</span>(<span class="kw-2">&amp;</span><span class="ident">app</span>, <span class="ident">test::TestRequest::get</span>().<span class="ident">uri</span>(<span class="ident">u</span>).<span class="ident">to_request</span>())
<span class="kw">let </span>resp =
test::call_service(<span class="kw-2">&amp;</span>app, test::TestRequest::get().uri(u).to_request())
.<span class="kw">await</span>;
<span class="macro">assert_eq!</span>(<span class="ident">resp</span>.<span class="ident">status</span>(), <span class="ident">StatusCode::OK</span>);
<span class="macro">assert_eq!</span>(resp.status(), StatusCode::OK);
}
}
}
</code></pre></div>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="mcaptcha" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>
</section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="mcaptcha" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.65.0 (897e37553 2022-11-02)" ></div></body></html>