1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-08-31 19:37:00 +02:00

Deploying to gh-pages from @ 74ec115161 🚀

This commit is contained in:
robjtede
2021-12-11 16:07:43 +00:00
parent c137843c1f
commit 884568a990
30 changed files with 194 additions and 226 deletions

View File

@@ -643,31 +643,20 @@
<span id="642">642</span>
<span id="643">643</span>
<span id="644">644</span>
<span id="645">645</span>
<span id="646">646</span>
<span id="647">647</span>
<span id="648">648</span>
<span id="649">649</span>
<span id="650">650</span>
<span id="651">651</span>
<span id="652">652</span>
<span id="653">653</span>
<span id="654">654</span>
<span id="655">655</span>
<span id="656">656</span>
<span id="657">657</span>
<span id="658">658</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">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">body</span>::{<span class="ident">EitherBody</span>, <span class="ident">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>},
<span class="ident">error</span>::{<span class="ident">Error</span>, <span class="prelude-ty">Result</span>},
<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="ident">error::HttpError</span>,
<span class="ident">http</span>::{
<span class="ident">header</span>::{<span class="ident">HeaderName</span>, <span class="ident">HeaderValue</span>},
<span class="ident">Method</span>, <span class="ident">Uri</span>,
},
<span class="ident">Either</span>, <span class="ident">Error</span>, <span class="prelude-ty">Result</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>;
@@ -679,7 +668,7 @@
<span class="doccomment">/// Additionally, always causes first error (if any) to be reported during initialization.</span>
<span class="kw">fn</span> <span class="ident">cors</span><span class="op">&lt;</span><span class="lifetime">&#39;a</span><span class="op">&gt;</span>(
<span class="ident">inner</span>: <span class="kw-2">&amp;</span><span class="lifetime">&#39;a</span> <span class="kw-2">mut</span> <span class="ident">Rc</span><span class="op">&lt;</span><span class="ident">Inner</span><span class="op">&gt;</span>,
<span class="ident">err</span>: <span class="kw-2">&amp;</span><span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">Either</span><span class="op">&lt;</span><span class="ident">http::Error</span>, <span class="ident">CorsError</span><span class="op">&gt;</span><span class="op">&gt;</span>,
<span class="ident">err</span>: <span class="kw-2">&amp;</span><span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">Either</span><span class="op">&lt;</span><span class="ident">HttpError</span>, <span class="ident">CorsError</span><span class="op">&gt;</span><span class="op">&gt;</span>,
) -&gt; <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="kw-2">&amp;</span><span class="lifetime">&#39;a</span> <span class="kw-2">mut</span> <span class="ident">Inner</span><span class="op">&gt;</span> {
<span class="kw">if</span> <span class="ident">err</span>.<span class="ident">is_some</span>() {
<span class="kw">return</span> <span class="prelude-val">None</span>;
@@ -733,7 +722,7 @@
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Debug</span>)]</span>
<span class="kw">pub</span> <span class="kw">struct</span> <span class="ident">Cors</span> {
<span class="ident">inner</span>: <span class="ident">Rc</span><span class="op">&lt;</span><span class="ident">Inner</span><span class="op">&gt;</span>,
<span class="ident">error</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">Either</span><span class="op">&lt;</span><span class="ident">http::Error</span>, <span class="ident">CorsError</span><span class="op">&gt;</span><span class="op">&gt;</span>,
<span class="ident">error</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">Either</span><span class="op">&lt;</span><span class="ident">HttpError</span>, <span class="ident">CorsError</span><span class="op">&gt;</span><span class="op">&gt;</span>,
}
<span class="kw">impl</span> <span class="ident">Cors</span> {
@@ -1149,7 +1138,7 @@
<span class="ident">B</span>: <span class="ident">MessageBody</span> <span class="op">+</span> <span class="lifetime">&#39;static</span>,
<span class="ident">B::Error</span>: <span class="ident">StdError</span>,
{
<span class="kw">type</span> <span class="ident">Response</span> <span class="op">=</span> <span class="ident">ServiceResponse</span>;
<span class="kw">type</span> <span class="ident">Response</span> <span class="op">=</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">EitherBody</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">Error</span>;
<span class="kw">type</span> <span class="ident">InitError</span> <span class="op">=</span> ();
<span class="kw">type</span> <span class="ident">Transform</span> <span class="op">=</span> <span class="ident">CorsMiddleware</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span>;
@@ -1230,15 +1219,13 @@
<span class="attribute">#[<span class="ident">cfg</span>(<span class="ident">test</span>)]</span>
<span class="kw">mod</span> <span class="ident">test</span> {
<span class="kw">use</span> <span class="ident">std::convert</span>::{<span class="ident">Infallible</span>, <span class="ident">TryInto</span>};
<span class="kw">use</span> <span class="ident">std::pin::Pin</span>;
<span class="kw">use</span> <span class="ident">std::task</span>::{<span class="ident">Context</span>, <span class="ident">Poll</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::{
<span class="ident">body</span>::{<span class="ident">BodySize</span>, <span class="ident">MessageBody</span>},
<span class="ident">body</span>,
<span class="ident">dev</span>::{<span class="ident">fn_service</span>, <span class="ident">Transform</span>},
<span class="ident">http</span>::{<span class="ident">HeaderName</span>, <span class="ident">StatusCode</span>},
<span class="ident">http</span>::{<span class="ident">header::HeaderName</span>, <span class="ident">StatusCode</span>},
<span class="ident">test</span>::{<span class="self">self</span>, <span class="ident">TestRequest</span>},
<span class="ident">web</span>::{<span class="ident">Bytes</span>, <span class="ident">HttpResponse</span>},
<span class="ident">web::HttpResponse</span>,
};
<span class="kw">use</span> <span class="kw">super</span>::<span class="kw-2">*</span>;
@@ -1293,23 +1280,8 @@
<span class="attribute">#[<span class="ident">actix_rt::test</span>]</span>
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">middleware_generic_over_body_type</span>() {
<span class="kw">struct</span> <span class="ident">Foo</span>;
<span class="kw">impl</span> <span class="ident">MessageBody</span> <span class="kw">for</span> <span class="ident">Foo</span> {
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">std::io::Error</span>;
<span class="kw">fn</span> <span class="ident">size</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="ident">BodySize</span> {
<span class="ident">BodySize::None</span>
}
<span class="kw">fn</span> <span class="ident">poll_next</span>(
<span class="self">self</span>: <span class="ident">Pin</span><span class="op">&lt;</span><span class="kw-2">&amp;mut</span> <span class="self">Self</span><span class="op">&gt;</span>,
<span class="kw">_</span>: <span class="kw-2">&amp;mut</span> <span class="ident">Context</span><span class="op">&lt;</span><span class="lifetime">&#39;_</span><span class="op">&gt;</span>,
) -&gt; <span class="ident">Poll</span><span class="op">&lt;</span><span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">Bytes</span>, <span class="ident"><span class="self">Self</span>::Error</span><span class="op">&gt;</span><span class="op">&gt;</span><span class="op">&gt;</span> {
<span class="ident">Poll::Ready</span>(<span class="prelude-val">None</span>)
}
}
<span class="kw">let</span> <span class="ident">srv</span> <span class="op">=</span> <span class="ident">fn_service</span>(<span class="op">|</span><span class="ident">req</span>: <span class="ident">ServiceRequest</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> {
<span class="prelude-val">Ok</span>(<span class="ident">req</span>.<span class="ident">into_response</span>(<span class="ident">HttpResponse::Ok</span>().<span class="ident">message_body</span>(<span class="ident">Foo</span>)<span class="question-mark">?</span>))
<span class="prelude-val">Ok</span>(<span class="ident">req</span>.<span class="ident">into_response</span>(<span class="ident">HttpResponse::Ok</span>().<span class="ident">message_body</span>(<span class="ident">body::None::new</span>())<span class="question-mark">?</span>))
});
<span class="ident">Cors::default</span>().<span class="ident">new_transform</span>(<span class="ident">srv</span>).<span class="kw">await</span>.<span class="ident">unwrap</span>();

View File

@@ -58,35 +58,35 @@
<span class="attribute">#[<span class="ident">non_exhaustive</span>]</span>
<span class="kw">pub</span> <span class="kw">enum</span> <span class="ident">CorsError</span> {
<span class="doccomment">/// Allowed origin argument must not be wildcard (`*`).</span>
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">&quot;`allowed_origin` argument must not be wildcard (`*`).&quot;</span>)]</span>
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">&quot;`allowed_origin` argument must not be wildcard (`*`)&quot;</span>)]</span>
<span class="ident">WildcardOrigin</span>,
<span class="doccomment">/// Request header `Origin` is required but was not provided.</span>
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">&quot;Request header `Origin` is required but was not provided.&quot;</span>)]</span>
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">&quot;Request header `Origin` is required but was not provided&quot;</span>)]</span>
<span class="ident">MissingOrigin</span>,
<span class="doccomment">/// Request header `Access-Control-Request-Method` is required but is missing.</span>
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">&quot;Request header `Access-Control-Request-Method` is required but is missing.&quot;</span>)]</span>
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">&quot;Request header `Access-Control-Request-Method` is required but is missing&quot;</span>)]</span>
<span class="ident">MissingRequestMethod</span>,
<span class="doccomment">/// Request header `Access-Control-Request-Method` has an invalid value.</span>
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">&quot;Request header `Access-Control-Request-Method` has an invalid value.&quot;</span>)]</span>
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">&quot;Request header `Access-Control-Request-Method` has an invalid value&quot;</span>)]</span>
<span class="ident">BadRequestMethod</span>,
<span class="doccomment">/// Request header `Access-Control-Request-Headers` has an invalid value.</span>
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">&quot;Request header `Access-Control-Request-Headers` has an invalid value.&quot;</span>)]</span>
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">&quot;Request header `Access-Control-Request-Headers` has an invalid value&quot;</span>)]</span>
<span class="ident">BadRequestHeaders</span>,
<span class="doccomment">/// Origin is not allowed to make this request.</span>
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">&quot;Origin is not allowed to make this request.&quot;</span>)]</span>
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">&quot;Origin is not allowed to make this request&quot;</span>)]</span>
<span class="ident">OriginNotAllowed</span>,
<span class="doccomment">/// Request method is not allowed.</span>
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">&quot;Requested method is not allowed.&quot;</span>)]</span>
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">&quot;Requested method is not allowed&quot;</span>)]</span>
<span class="ident">MethodNotAllowed</span>,
<span class="doccomment">/// One or more request headers are not allowed.</span>
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">&quot;One or more request headers are not allowed.&quot;</span>)]</span>
<span class="attribute">#[<span class="ident">display</span>(<span class="ident">fmt</span> <span class="op">=</span> <span class="string">&quot;One or more request headers are not allowed&quot;</span>)]</span>
<span class="ident">HeadersNotAllowed</span>,
}
@@ -96,7 +96,7 @@
}
<span class="kw">fn</span> <span class="ident">error_response</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="ident">HttpResponse</span> {
<span class="ident">HttpResponse::with_body</span>(<span class="ident">StatusCode::BAD_REQUEST</span>, <span class="self">self</span>.<span class="ident">to_string</span>().<span class="ident">into</span>())
<span class="ident">HttpResponse::with_body</span>(<span class="ident">StatusCode::BAD_REQUEST</span>, <span class="self">self</span>.<span class="ident">to_string</span>()).<span class="ident">map_into_boxed_body</span>()
}
}
</code></pre></div>

View File

@@ -326,6 +326,9 @@
<span id="325">325</span>
<span id="326">326</span>
<span id="327">327</span>
<span id="328">328</span>
<span id="329">329</span>
<span id="330">330</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::TryFrom</span>, <span class="ident">convert::TryInto</span>, <span class="ident">fmt</span>, <span class="ident">rc::Rc</span>};
<span class="kw">use</span> <span class="ident">actix_web</span>::{
@@ -533,7 +536,10 @@
<span class="kw">use</span> <span class="ident">actix_web</span>::{
<span class="ident">dev::Transform</span>,
<span class="ident">http</span>::{<span class="ident">header</span>, <span class="ident">HeaderValue</span>, <span class="ident">Method</span>, <span class="ident">StatusCode</span>},
<span class="ident">http</span>::{
<span class="ident">header</span>::{<span class="self">self</span>, <span class="ident">HeaderValue</span>},
<span class="ident">Method</span>, <span class="ident">StatusCode</span>,
},
<span class="ident">test</span>::{<span class="self">self</span>, <span class="ident">TestRequest</span>},
};

View File

@@ -240,11 +240,16 @@
<span id="239">239</span>
<span id="240">240</span>
<span id="241">241</span>
<span id="242">242</span>
<span id="243">243</span>
<span id="244">244</span>
<span id="245">245</span>
<span id="246">246</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_utils::future::ok</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">body</span>::{<span class="ident">EitherBody</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>},
<span class="ident">error</span>::{<span class="ident">Error</span>, <span class="prelude-ty">Result</span>},
<span class="ident">http</span>::{
@@ -253,7 +258,7 @@
},
<span class="ident">HttpResponse</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">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="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>};
@@ -376,11 +381,6 @@
}
}
<span class="kw">type</span> <span class="ident">CorsMiddlewareServiceFuture</span> <span class="op">=</span> <span class="ident">Either</span><span class="op">&lt;</span>
<span class="ident">Ready</span><span class="op">&lt;</span><span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">ServiceResponse</span>, <span class="ident">Error</span><span class="op">&gt;</span><span class="op">&gt;</span>,
<span class="ident">LocalBoxFuture</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">ServiceResponse</span>, <span class="ident">Error</span><span class="op">&gt;</span><span class="op">&gt;</span>,
<span class="op">&gt;</span>;
<span class="kw">impl</span><span class="op">&lt;</span><span class="ident">S</span>, <span class="ident">B</span><span class="op">&gt;</span> <span class="ident">Service</span><span class="op">&lt;</span><span class="ident">ServiceRequest</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">CorsMiddleware</span><span class="op">&lt;</span><span class="ident">S</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">S</span>: <span class="ident">Service</span><span class="op">&lt;</span><span class="ident">ServiceRequest</span>, <span class="ident">Response</span> <span class="op">=</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span>, <span class="ident">Error</span> <span class="op">=</span> <span class="ident">Error</span><span class="op">&gt;</span>,
@@ -388,9 +388,9 @@
<span class="ident">B</span>: <span class="ident">MessageBody</span> <span class="op">+</span> <span class="lifetime">&#39;static</span>,
<span class="ident">B::Error</span>: <span class="ident">StdError</span>,
{
<span class="kw">type</span> <span class="ident">Response</span> <span class="op">=</span> <span class="ident">ServiceResponse</span>;
<span class="kw">type</span> <span class="ident">Response</span> <span class="op">=</span> <span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">EitherBody</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">Error</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">CorsMiddlewareServiceFuture</span>;
<span class="kw">type</span> <span class="ident">Future</span> <span class="op">=</span> <span class="ident">LocalBoxFuture</span><span class="op">&lt;</span><span class="lifetime">&#39;static</span>, <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">ServiceResponse</span><span class="op">&lt;</span><span class="ident">EitherBody</span><span class="op">&lt;</span><span class="ident">B</span><span class="op">&gt;</span><span class="op">&gt;</span>, <span class="ident">Error</span><span class="op">&gt;</span><span class="op">&gt;</span>;
<span class="macro">actix_service::forward_ready!</span>(<span class="ident">service</span>);
@@ -398,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">&amp;&amp;</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">&amp;</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">&amp;</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">ok</span>(<span class="ident">res</span>.<span class="ident">map_into_right_body</span>()).<span class="ident">boxed_local</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>();
@@ -406,27 +406,37 @@
<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">&quot;origin validation failed; inner service is not called&quot;</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">ok</span>(<span class="ident">req</span>.<span class="ident">error_response</span>(<span class="ident">err</span>).<span class="ident">map_into_right_body</span>()).<span class="ident">boxed_local</span>();
}
}
<span class="kw">let</span> (<span class="ident">req</span>, <span class="ident">pl</span>) <span class="op">=</span> <span class="ident">req</span>.<span class="ident">into_parts</span>();
<span class="kw">let</span> <span class="ident">req2</span> <span class="op">=</span> <span class="ident">req</span>.<span class="ident">clone</span>();
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">ServiceRequest::from_parts</span>(<span class="ident">req</span>, <span class="ident">pl</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">&amp;</span><span class="self">self</span>.<span class="ident">inner</span>);
<span class="kw">let</span> <span class="ident">fut</span> <span class="op">=</span> <span class="self">self</span>.<span class="ident">service</span>.<span class="ident">call</span>(<span class="ident">req</span>);
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="kw">async</span> <span class="kw">move</span> {
<span class="kw">async</span> <span class="kw">move</span> {
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="ident">fut</span>.<span class="kw">await</span>;
<span class="kw">if</span> <span class="ident">origin</span>.<span class="ident">is_some</span>() {
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="ident">res</span><span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="kw">match</span> <span class="ident">res</span> {
<span class="prelude-val">Ok</span>(<span class="ident">res</span>) =&gt; <span class="ident">res</span>,
<span class="prelude-val">Err</span>(<span class="ident">err</span>) =&gt; {
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="ident">HttpResponse::from_error</span>(<span class="ident">err</span>);
<span class="kw">let</span> <span class="ident">res</span> <span class="op">=</span> <span class="ident">ServiceResponse::new</span>(<span class="ident">req2</span>, <span class="ident">res</span>);
<span class="kw">return</span> <span class="prelude-val">Ok</span>(<span class="ident">res</span>.<span class="ident">map_into_right_body</span>());
}
};
<span class="prelude-val">Ok</span>(<span class="ident"><span class="self">Self</span>::augment_response</span>(<span class="kw-2">&amp;</span><span class="ident">inner</span>, <span class="ident">res</span>))
} <span class="kw">else</span> {
<span class="ident">res</span>
}
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">res</span><span class="op">|</span> <span class="ident">res</span>.<span class="ident">map_into_left_body</span>())
}
.<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">boxed_local</span>()
}
}
}