mirror of
https://github.com/actix/actix-extras.git
synced 2025-08-31 19:37:00 +02:00
Deploying to gh-pages from @ 56051786a6
🚀
This commit is contained in:
@@ -661,6 +661,7 @@
|
||||
<span class="ident">collections::HashSet</span>, <span class="ident">convert::TryInto</span>, <span class="ident">error::Error</span> <span class="kw">as</span> <span class="ident">StdError</span>, <span class="ident">iter::FromIterator</span>, <span class="ident">rc::Rc</span>,
|
||||
};
|
||||
|
||||
<span class="kw">use</span> <span class="ident">actix_utils::future</span>::{<span class="self">self</span>, <span class="ident">Ready</span>};
|
||||
<span class="kw">use</span> <span class="ident">actix_web</span>::{
|
||||
<span class="ident">body::MessageBody</span>,
|
||||
<span class="ident">dev</span>::{<span class="ident">RequestHead</span>, <span class="ident">Service</span>, <span class="ident">ServiceRequest</span>, <span class="ident">ServiceResponse</span>, <span class="ident">Transform</span>},
|
||||
@@ -668,7 +669,6 @@
|
||||
<span class="ident">http</span>::{<span class="self">self</span>, <span class="ident">header::HeaderName</span>, <span class="ident">Error</span> <span class="kw">as</span> <span class="ident">HttpError</span>, <span class="ident">HeaderValue</span>, <span class="ident">Method</span>, <span class="ident">Uri</span>},
|
||||
<span class="ident">Either</span>,
|
||||
};
|
||||
<span class="kw">use</span> <span class="ident">futures_util::future</span>::{<span class="self">self</span>, <span class="ident">Ready</span>};
|
||||
<span class="kw">use</span> <span class="ident">log::error</span>;
|
||||
<span class="kw">use</span> <span class="ident">once_cell::sync::Lazy</span>;
|
||||
<span class="kw">use</span> <span class="ident">smallvec::smallvec</span>;
|
||||
|
@@ -239,8 +239,10 @@
|
||||
<span id="238">238</span>
|
||||
<span id="239">239</span>
|
||||
<span id="240">240</span>
|
||||
<span id="241">241</span>
|
||||
</pre><pre class="rust"><code><span class="kw">use</span> <span class="ident">std</span>::{<span class="ident">collections::HashSet</span>, <span class="ident">convert::TryInto</span>, <span class="ident">error::Error</span> <span class="kw">as</span> <span class="ident">StdError</span>, <span class="ident">rc::Rc</span>};
|
||||
|
||||
<span class="kw">use</span> <span class="ident">actix_utils::future</span>::{<span class="ident">ok</span>, <span class="ident">Either</span>, <span class="ident">Ready</span>};
|
||||
<span class="kw">use</span> <span class="ident">actix_web</span>::{
|
||||
<span class="ident">body</span>::{<span class="ident">AnyBody</span>, <span class="ident">MessageBody</span>},
|
||||
<span class="ident">dev</span>::{<span class="ident">Service</span>, <span class="ident">ServiceRequest</span>, <span class="ident">ServiceResponse</span>},
|
||||
@@ -251,7 +253,7 @@
|
||||
},
|
||||
<span class="ident">HttpResponse</span>,
|
||||
};
|
||||
<span class="kw">use</span> <span class="ident">futures_util::future</span>::{<span class="ident">ok</span>, <span class="ident">Either</span>, <span class="ident">FutureExt</span> <span class="kw">as</span> <span class="kw">_</span>, <span class="ident">LocalBoxFuture</span>, <span class="ident">Ready</span>, <span class="ident">TryFutureExt</span> <span class="kw">as</span> <span class="kw">_</span>};
|
||||
<span class="kw">use</span> <span class="ident">futures_util::future</span>::{<span class="ident">FutureExt</span> <span class="kw">as</span> <span class="kw">_</span>, <span class="ident">LocalBoxFuture</span>, <span class="ident">TryFutureExt</span> <span class="kw">as</span> <span class="kw">_</span>};
|
||||
<span class="kw">use</span> <span class="ident">log::debug</span>;
|
||||
|
||||
<span class="kw">use</span> <span class="kw">crate</span>::{<span class="ident">builder::intersperse_header_values</span>, <span class="ident">AllOrSome</span>, <span class="ident">Inner</span>};
|
||||
@@ -396,7 +398,7 @@
|
||||
<span class="kw">if</span> <span class="self">self</span>.<span class="ident">inner</span>.<span class="ident">preflight</span> <span class="op">&&</span> <span class="ident">req</span>.<span class="ident">method</span>() <span class="op">==</span> <span class="ident">Method::OPTIONS</span> {
|
||||
<span class="kw">let</span> <span class="ident">inner</span> <span class="op">=</span> <span class="ident">Rc::clone</span>(<span class="kw-2">&</span><span class="self">self</span>.<span class="ident">inner</span>);
|
||||
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="ident"><span class="self">Self</span>::handle_preflight</span>(<span class="kw-2">&</span><span class="ident">inner</span>, <span class="ident">req</span>);
|
||||
<span class="ident">Either::Left</span>(<span class="ident">ok</span>(<span class="ident">res</span>))
|
||||
<span class="ident">Either::left</span>(<span class="ident">ok</span>(<span class="ident">res</span>))
|
||||
} <span class="kw">else</span> {
|
||||
<span class="kw">let</span> <span class="ident">origin</span> <span class="op">=</span> <span class="ident">req</span>.<span class="ident">headers</span>().<span class="ident">get</span>(<span class="ident">header::ORIGIN</span>).<span class="ident">cloned</span>();
|
||||
|
||||
@@ -404,7 +406,7 @@
|
||||
<span class="comment">// Only check requests with a origin header.</span>
|
||||
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Err</span>(<span class="ident">err</span>) <span class="op">=</span> <span class="self">self</span>.<span class="ident">inner</span>.<span class="ident">validate_origin</span>(<span class="ident">req</span>.<span class="ident">head</span>()) {
|
||||
<span class="macro">debug!</span>(<span class="string">"origin validation failed; inner service is not called"</span>);
|
||||
<span class="kw">return</span> <span class="ident">Either::Left</span>(<span class="ident">ok</span>(<span class="ident">req</span>.<span class="ident">error_response</span>(<span class="ident">err</span>)));
|
||||
<span class="kw">return</span> <span class="ident">Either::left</span>(<span class="ident">ok</span>(<span class="ident">req</span>.<span class="ident">error_response</span>(<span class="ident">err</span>)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,7 +426,7 @@
|
||||
.<span class="ident">map_ok</span>(<span class="op">|</span><span class="ident">res</span><span class="op">|</span> <span class="ident">res</span>.<span class="ident">map_body</span>(<span class="op">|</span><span class="kw">_</span>, <span class="ident">body</span><span class="op">|</span> <span class="ident">AnyBody::new_boxed</span>(<span class="ident">body</span>)))
|
||||
.<span class="ident">boxed_local</span>();
|
||||
|
||||
<span class="ident">Either::Right</span>(<span class="ident">res</span>)
|
||||
<span class="ident">Either::right</span>(<span class="ident">res</span>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user