mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-30 16:34:26 +02:00
Deploying to gh-pages from @ actix/actix-web@26efa64278 🚀
This commit is contained in:
11
actix_web/middleware/compat/struct.Compat.html
Normal file
11
actix_web/middleware/compat/struct.Compat.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../actix_web/middleware/struct.Compat.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../actix_web/middleware/struct.Compat.html">../../../actix_web/middleware/struct.Compat.html</a>...</p>
|
||||
<script>location.replace("../../../actix_web/middleware/struct.Compat.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
11
actix_web/middleware/compress/struct.Compress.html
Normal file
11
actix_web/middleware/compress/struct.Compress.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../actix_web/middleware/struct.Compress.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../actix_web/middleware/struct.Compress.html">../../../actix_web/middleware/struct.Compress.html</a>...</p>
|
||||
<script>location.replace("../../../actix_web/middleware/struct.Compress.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
11
actix_web/middleware/condition/struct.Condition.html
Normal file
11
actix_web/middleware/condition/struct.Condition.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../actix_web/middleware/struct.Condition.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../actix_web/middleware/struct.Condition.html">../../../actix_web/middleware/struct.Condition.html</a>...</p>
|
||||
<script>location.replace("../../../actix_web/middleware/struct.Condition.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../actix_web/middleware/struct.DefaultHeaders.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../actix_web/middleware/struct.DefaultHeaders.html">../../../actix_web/middleware/struct.DefaultHeaders.html</a>...</p>
|
||||
<script>location.replace("../../../actix_web/middleware/struct.DefaultHeaders.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
24
actix_web/middleware/enum.ErrorHandlerResponse.html
Normal file
24
actix_web/middleware/enum.ErrorHandlerResponse.html
Normal file
@ -0,0 +1,24 @@
|
||||
<!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="Return type for `ErrorHandlers` custom handlers."><title>ErrorHandlerResponse in actix_web::middleware - 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_web" data-themes="" data-resource-suffix="" data-rustdoc-version="1.80.0-nightly (bdbbb6c6a 2024-05-26)" data-channel="nightly" data-search-js="search-d52510db62a78183.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../../static.files/storage-118b08c4c78b968e.js"></script><script defer src="sidebar-items.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 enum"><!--[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_web/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_web/index.html"><img src="https://actix.rs/img/logo.png" alt="logo"></a><h2><a href="../../actix_web/index.html">actix_web</a><span class="version">4.6.0</span></h2></div><h2 class="location"><a href="#">ErrorHandlerResponse</a></h2><div class="sidebar-elems"><section><h3><a href="#variants">Variants</a></h3><ul class="block variant"><li><a href="#variant.Future">Future</a></li><li><a href="#variant.Response">Response</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-Freeze-for-ErrorHandlerResponse%3CB%3E">!Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-ErrorHandlerResponse%3CB%3E">!RefUnwindSafe</a></li><li><a href="#impl-Send-for-ErrorHandlerResponse%3CB%3E">!Send</a></li><li><a href="#impl-Sync-for-ErrorHandlerResponse%3CB%3E">!Sync</a></li><li><a href="#impl-UnwindSafe-for-ErrorHandlerResponse%3CB%3E">!UnwindSafe</a></li><li><a href="#impl-Unpin-for-ErrorHandlerResponse%3CB%3E">Unpin</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-T">From<T></a></li><li><a href="#impl-Instrument-for-T">Instrument</a></li><li><a href="#impl-Into%3CU%3E-for-T">Into<U></a></li><li><a href="#impl-Same-for-T">Same</a></li><li><a href="#impl-TryFrom%3CU%3E-for-T">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-T">TryInto<U></a></li><li><a href="#impl-VZip%3CV%3E-for-T">VZip<V></a></li><li><a href="#impl-WithSubscriber-for-T">WithSubscriber</a></li></ul></section><h2><a href="index.html">In actix_web::middleware</a></h2></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>Enum <a href="../index.html">actix_web</a>::<wbr><a href="index.html">middleware</a>::<wbr><a class="enum" href="#">ErrorHandlerResponse</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_web/middleware/err_handlers.rs.html#23-29">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>−</span>]</button></span></div><pre class="rust item-decl"><code>pub enum ErrorHandlerResponse<B> {
|
||||
Response(<a class="struct" href="../dev/struct.ServiceResponse.html" title="struct actix_web::dev::ServiceResponse">ServiceResponse</a><<a class="enum" href="../body/enum.EitherBody.html" title="enum actix_web::body::EitherBody">EitherBody</a><B>>),
|
||||
Future(LocalBoxFuture<'static, <a class="type" href="../type.Result.html" title="type actix_web::Result">Result</a><<a class="struct" href="../dev/struct.ServiceResponse.html" title="struct actix_web::dev::ServiceResponse">ServiceResponse</a><<a class="enum" href="../body/enum.EitherBody.html" title="enum actix_web::body::EitherBody">EitherBody</a><B>>, <a class="struct" href="../error/struct.Error.html" title="struct actix_web::error::Error">Error</a>>>),
|
||||
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Return type for <a href="struct.ErrorHandlers.html" title="struct actix_web::middleware::ErrorHandlers"><code>ErrorHandlers</code></a> custom handlers.</p>
|
||||
</div></details><h2 id="variants" class="variants section-header">Variants<a href="#variants" class="anchor">§</a></h2><div class="variants"><section id="variant.Response" class="variant"><a href="#variant.Response" class="anchor">§</a><h3 class="code-header">Response(<a class="struct" href="../dev/struct.ServiceResponse.html" title="struct actix_web::dev::ServiceResponse">ServiceResponse</a><<a class="enum" href="../body/enum.EitherBody.html" title="enum actix_web::body::EitherBody">EitherBody</a><B>>)</h3></section><div class="docblock"><p>Immediate HTTP response.</p>
|
||||
</div><section id="variant.Future" class="variant"><a href="#variant.Future" class="anchor">§</a><h3 class="code-header">Future(LocalBoxFuture<'static, <a class="type" href="../type.Result.html" title="type actix_web::Result">Result</a><<a class="struct" href="../dev/struct.ServiceResponse.html" title="struct actix_web::dev::ServiceResponse">ServiceResponse</a><<a class="enum" href="../body/enum.EitherBody.html" title="enum actix_web::body::EitherBody">EitherBody</a><B>>, <a class="struct" href="../error/struct.Error.html" title="struct actix_web::error::Error">Error</a>>>)</h3></section><div class="docblock"><p>A future that resolves to an HTTP response.</p>
|
||||
</div></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-ErrorHandlerResponse%3CB%3E" class="impl"><a href="#impl-Freeze-for-ErrorHandlerResponse%3CB%3E" class="anchor">§</a><h3 class="code-header">impl<B> !<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="enum" href="enum.ErrorHandlerResponse.html" title="enum actix_web::middleware::ErrorHandlerResponse">ErrorHandlerResponse</a><B></h3></section><section id="impl-RefUnwindSafe-for-ErrorHandlerResponse%3CB%3E" class="impl"><a href="#impl-RefUnwindSafe-for-ErrorHandlerResponse%3CB%3E" class="anchor">§</a><h3 class="code-header">impl<B> !<a class="trait" href="https://doc.rust-lang.org/nightly/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="enum" href="enum.ErrorHandlerResponse.html" title="enum actix_web::middleware::ErrorHandlerResponse">ErrorHandlerResponse</a><B></h3></section><section id="impl-Send-for-ErrorHandlerResponse%3CB%3E" class="impl"><a href="#impl-Send-for-ErrorHandlerResponse%3CB%3E" class="anchor">§</a><h3 class="code-header">impl<B> !<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="enum" href="enum.ErrorHandlerResponse.html" title="enum actix_web::middleware::ErrorHandlerResponse">ErrorHandlerResponse</a><B></h3></section><section id="impl-Sync-for-ErrorHandlerResponse%3CB%3E" class="impl"><a href="#impl-Sync-for-ErrorHandlerResponse%3CB%3E" class="anchor">§</a><h3 class="code-header">impl<B> !<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="enum" href="enum.ErrorHandlerResponse.html" title="enum actix_web::middleware::ErrorHandlerResponse">ErrorHandlerResponse</a><B></h3></section><section id="impl-Unpin-for-ErrorHandlerResponse%3CB%3E" class="impl"><a href="#impl-Unpin-for-ErrorHandlerResponse%3CB%3E" class="anchor">§</a><h3 class="code-header">impl<B> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="enum" href="enum.ErrorHandlerResponse.html" title="enum actix_web::middleware::ErrorHandlerResponse">ErrorHandlerResponse</a><B><div class="where">where
|
||||
B: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h3></section><section id="impl-UnwindSafe-for-ErrorHandlerResponse%3CB%3E" class="impl"><a href="#impl-UnwindSafe-for-ErrorHandlerResponse%3CB%3E" class="anchor">§</a><h3 class="code-header">impl<B> !<a class="trait" href="https://doc.rust-lang.org/nightly/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="enum" href="enum.ErrorHandlerResponse.html" title="enum actix_web::middleware::ErrorHandlerResponse">ErrorHandlerResponse</a><B></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#140">source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
|
||||
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#141">source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#208">source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210">source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#216">source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217">source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#765">source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#768">source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
|
||||
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Instrument-for-T" class="impl"><a href="#impl-Instrument-for-T" class="anchor">§</a><h3 class="code-header">impl<T> Instrument for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.instrument" class="method trait-impl"><a href="#method.instrument" class="anchor">§</a><h4 class="code-header">fn <a class="fn">instrument</a>(self, span: Span) -> Instrumented<Self></h4></section></summary><div class='docblock'>Instruments this type with the provided [<code>Span</code>], returning an
|
||||
<code>Instrumented</code> wrapper. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.in_current_span" class="method trait-impl"><a href="#method.in_current_span" class="anchor">§</a><h4 class="code-header">fn <a class="fn">in_current_span</a>(self) -> Instrumented<Self></h4></section></summary><div class='docblock'>Instruments this type with the <a href="super::Span::current()">current</a> <a href="crate::Span"><code>Span</code></a>, returning an
|
||||
<code>Instrumented</code> wrapper. <a>Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#748-750">source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T<div class="where">where
|
||||
U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#758">source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
|
||||
<p>That is, this conversion is whatever the implementation of
|
||||
<code><a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for U</code> chooses to do.</p>
|
||||
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Same-for-T" class="impl"><a class="src rightside" href="https://docs.rs/typenum/1.17.0/src/typenum/type_operators.rs.html#34">source</a><a href="#impl-Same-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://docs.rs/typenum/1.17.0/typenum/type_operators/trait.Same.html" title="trait typenum::type_operators::Same">Same</a> for T</h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Output" class="associatedtype trait-impl"><a href="#associatedtype.Output" class="anchor">§</a><h4 class="code-header">type <a href="https://docs.rs/typenum/1.17.0/typenum/type_operators/trait.Same.html#associatedtype.Output" class="associatedtype">Output</a> = T</h4></section></summary><div class='docblock'>Should always be <code>Self</code></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#805-807">source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T<div class="where">where
|
||||
U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#812">source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#790-792">source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T<div class="where">where
|
||||
U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#797">source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-VZip%3CV%3E-for-T" class="impl"><a href="#impl-VZip%3CV%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<V, T> VZip<V> for T<div class="where">where
|
||||
V: MultiLane<T>,</div></h3></section></summary><div class="impl-items"><section id="method.vzip" class="method trait-impl"><a href="#method.vzip" class="anchor">§</a><h4 class="code-header">fn <a class="fn">vzip</a>(self) -> V</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-WithSubscriber-for-T" class="impl"><a href="#impl-WithSubscriber-for-T" class="anchor">§</a><h3 class="code-header">impl<T> WithSubscriber for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.with_subscriber" class="method trait-impl"><a href="#method.with_subscriber" class="anchor">§</a><h4 class="code-header">fn <a class="fn">with_subscriber</a><S>(self, subscriber: S) -> WithDispatch<Self><div class="where">where
|
||||
S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><Dispatch>,</div></h4></section></summary><div class='docblock'>Attaches the provided <a href="super::Subscriber"><code>Subscriber</code></a> to this type, returning a
|
||||
[<code>WithDispatch</code>] wrapper. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.with_current_subscriber" class="method trait-impl"><a href="#method.with_current_subscriber" class="anchor">§</a><h4 class="code-header">fn <a class="fn">with_current_subscriber</a>(self) -> WithDispatch<Self></h4></section></summary><div class='docblock'>Attaches the current <a href="crate::dispatcher#setting-the-default-subscriber">default</a> <a href="super::Subscriber"><code>Subscriber</code></a> to this type, returning a
|
||||
[<code>WithDispatch</code>] wrapper. <a>Read more</a></div></details></div></details></div></section></div></main></body></html>
|
30
actix_web/middleware/enum.TrailingSlash.html
Normal file
30
actix_web/middleware/enum.TrailingSlash.html
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../actix_web/middleware/enum.ErrorHandlerResponse.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../actix_web/middleware/enum.ErrorHandlerResponse.html">../../../actix_web/middleware/enum.ErrorHandlerResponse.html</a>...</p>
|
||||
<script>location.replace("../../../actix_web/middleware/enum.ErrorHandlerResponse.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
11
actix_web/middleware/err_handlers/struct.ErrorHandlers.html
Normal file
11
actix_web/middleware/err_handlers/struct.ErrorHandlers.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../actix_web/middleware/struct.ErrorHandlers.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../actix_web/middleware/struct.ErrorHandlers.html">../../../actix_web/middleware/struct.ErrorHandlers.html</a>...</p>
|
||||
<script>location.replace("../../../actix_web/middleware/struct.ErrorHandlers.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
165
actix_web/middleware/index.html
Normal file
165
actix_web/middleware/index.html
Normal file
@ -0,0 +1,165 @@
|
||||
<!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="A collection of common middleware."><title>actix_web::middleware - 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_web" data-themes="" data-resource-suffix="" data-rustdoc-version="1.80.0-nightly (bdbbb6c6a 2024-05-26)" data-channel="nightly" data-search-js="search-d52510db62a78183.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../../static.files/storage-118b08c4c78b968e.js"></script><script defer src="../sidebar-items.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"><!--[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_web/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_web/index.html"><img src="https://actix.rs/img/logo.png" alt="logo"></a><h2><a href="../../actix_web/index.html">actix_web</a><span class="version">4.6.0</span></h2></div><h2 class="location"><a href="#">Module middleware</a></h2><div class="sidebar-elems"><section><ul class="block"><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li></ul></section><h2><a href="../index.html">In crate actix_web</a></h2></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>Module <a href="../index.html">actix_web</a>::<wbr><a class="mod" href="#">middleware</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_web/middleware/mod.rs.html#1-283">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>A collection of common middleware.</p>
|
||||
<h2 id="what-is-middleware"><a class="doc-anchor" href="#what-is-middleware">§</a>What Is Middleware?</h2>
|
||||
<p>Actix Web’s middleware system allows us to add additional behavior to request/response
|
||||
processing. Middleware can hook into incoming request and outgoing response processes, enabling
|
||||
us to modify requests and responses as well as halt request processing to return a response
|
||||
early.</p>
|
||||
<p>Typically, middleware is involved in the following actions:</p>
|
||||
<ul>
|
||||
<li>Pre-process the request (e.g., <a href="struct.NormalizePath.html" title="struct actix_web::middleware::NormalizePath">normalizing paths</a>)</li>
|
||||
<li>Post-process a response (e.g., <a href="struct.Logger.html" title="struct actix_web::middleware::Logger">logging</a>)</li>
|
||||
<li>Modify application state (through <a href="../dev/struct.ServiceRequest.html" title="struct actix_web::dev::ServiceRequest"><code>ServiceRequest</code></a>)</li>
|
||||
<li>Access external services (e.g., <a href="https://docs.rs/actix-session">sessions</a>, etc.)</li>
|
||||
</ul>
|
||||
<p>Middleware is registered for each <a href="../struct.App.html" title="struct actix_web::App"><code>App</code></a>, <a href="../struct.Scope.html" title="struct actix_web::Scope"><code>Scope</code></a>, or
|
||||
<a href="../struct.Resource.html" title="struct actix_web::Resource"><code>Resource</code></a> and executed in opposite order as registration. In general, a
|
||||
middleware is a pair of types that implements the <a href="../dev/trait.Service.html" title="trait actix_web::dev::Service"><code>Service</code></a> trait and <a href="../dev/trait.Transform.html" title="trait actix_web::dev::Transform"><code>Transform</code></a> trait,
|
||||
respectively. The <a href="../dev/trait.Transform.html#tymethod.new_transform" title="method actix_web::dev::Transform::new_transform"><code>new_transform</code></a> and <a href="../dev/trait.Service.html#tymethod.call" title="method actix_web::dev::Service::call"><code>call</code></a> methods must return a <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future"><code>Future</code></a>, though it
|
||||
can often be <a href="actix_utils::future::Ready">an immediately-ready one</a>.</p>
|
||||
<h2 id="ordering"><a class="doc-anchor" href="#ordering">§</a>Ordering</h2>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[get(<span class="string">"/"</span>)]
|
||||
</span><span class="kw">async fn </span>service(a: ExtractorA, b: ExtractorB) -> <span class="kw">impl </span>Responder { <span class="string">"Hello, World!" </span>}
|
||||
|
||||
<span class="kw">let </span>app = App::new()
|
||||
.wrap(MiddlewareA::default())
|
||||
.wrap(MiddlewareB::default())
|
||||
.wrap(MiddlewareC::default())
|
||||
.service(service);</code></pre></div>
|
||||
<div class="example-wrap"><pre class="language-plain"><code> Request
|
||||
⭣
|
||||
╭────────────────────┼────╮
|
||||
│ MiddlewareC │ │
|
||||
│ ╭──────────────────┼───╮│
|
||||
│ │ MiddlewareB │ ││
|
||||
│ │ ╭────────────────┼──╮││
|
||||
│ │ │ MiddlewareA │ │││
|
||||
│ │ │ ╭──────────────┼─╮│││
|
||||
│ │ │ │ ExtractorA │ ││││
|
||||
│ │ │ ├┈┈┈┈┈┈┈┈┈┈┈┈┈┈┼┈┤│││
|
||||
│ │ │ │ ExtractorB │ ││││
|
||||
│ │ │ ├┈┈┈┈┈┈┈┈┈┈┈┈┈┈┼┈┤│││
|
||||
│ │ │ │ service │ ││││
|
||||
│ │ │ ╰──────────────┼─╯│││
|
||||
│ │ ╰────────────────┼──╯││
|
||||
│ ╰──────────────────┼───╯│
|
||||
╰────────────────────┼────╯
|
||||
⭣
|
||||
Response
|
||||
</code></pre></div>
|
||||
<p>The request <em>first</em> gets processed by the middleware specified <em>last</em> - <code>MiddlewareC</code>. It passes
|
||||
the request (modified a modified one) to the next middleware - <code>MiddlewareB</code> - <em>or</em> directly
|
||||
responds to the request (e.g. when the request was invalid or an error occurred). <code>MiddlewareB</code>
|
||||
processes the request as well and passes it to <code>MiddlewareA</code>, which then passes it to the
|
||||
<a href="../dev/trait.Service.html" title="trait actix_web::dev::Service"><code>Service</code></a>. In the <a href="../dev/trait.Service.html" title="trait actix_web::dev::Service"><code>Service</code></a>, the extractors will run first. They don’t pass the request on,
|
||||
but only view it (see <a href="../trait.FromRequest.html" title="trait actix_web::FromRequest"><code>FromRequest</code></a>). After the <a href="../dev/trait.Service.html" title="trait actix_web::dev::Service"><code>Service</code></a> responds to the request, the
|
||||
response is passed back through <code>MiddlewareA</code>, <code>MiddlewareB</code>, and <code>MiddlewareC</code>.</p>
|
||||
<p>As you register middleware using <a href="../struct.App.html#method.wrap" title="method actix_web::App::wrap"><code>wrap</code></a> and <a href="../struct.App.html#method.wrap_fn" title="method actix_web::App::wrap_fn"><code>wrap_fn</code></a>
|
||||
in the <a href="../struct.App.html" title="struct actix_web::App"><code>App</code></a> builder, imagine wrapping layers around an inner <a href="../struct.App.html" title="struct actix_web::App"><code>App</code></a>. The first middleware
|
||||
layer exposed to a Request is the outermost layer (i.e., the <em>last</em> registered in the builder
|
||||
chain, in the example above: <code>MiddlewareC</code>). Consequently, the <em>first</em> middleware registered in
|
||||
the builder chain is the <em>last</em> to start executing during request processing (<code>MiddlewareA</code>).
|
||||
Ordering is less obvious when wrapped services also have middleware applied. In this case,
|
||||
middleware are run in reverse order for <a href="../struct.App.html" title="struct actix_web::App"><code>App</code></a> <em>and then</em> in reverse order for the wrapped
|
||||
service.</p>
|
||||
<h2 id="middleware-traits"><a class="doc-anchor" href="#middleware-traits">§</a>Middleware Traits</h2><h3 id="transforms-req"><a class="doc-anchor" href="#transforms-req">§</a><code>Transform<S, Req></code></h3>
|
||||
<p>The <a href="../dev/trait.Transform.html" title="trait actix_web::dev::Transform"><code>Transform</code></a> trait is the builder for the actual <a href="../dev/trait.Service.html" title="trait actix_web::dev::Service"><code>Service</code></a>s that handle the requests. All
|
||||
the middleware you pass to the <code>wrap</code> methods implement this trait. During construction, each
|
||||
thread assembles a chain of <a href="../dev/trait.Service.html" title="trait actix_web::dev::Service"><code>Service</code></a>s by calling <a href="../dev/trait.Transform.html#tymethod.new_transform" title="method actix_web::dev::Transform::new_transform"><code>new_transform</code></a> and passing the next
|
||||
<a href="../dev/trait.Service.html" title="trait actix_web::dev::Service"><code>Service</code></a> (<code>S</code>) in the chain. The created <a href="../dev/trait.Service.html" title="trait actix_web::dev::Service"><code>Service</code></a> handles requests of type <code>Req</code>.</p>
|
||||
<p>In the example from the <a href="#ordering">ordering</a> section, the chain would be:</p>
|
||||
<div class="example-wrap"><pre class="language-plain"><code>MiddlewareCService {
|
||||
next: MiddlewareBService {
|
||||
next: MiddlewareAService { ... }
|
||||
}
|
||||
}
|
||||
</code></pre></div><h3 id="servicereq"><a class="doc-anchor" href="#servicereq">§</a><code>Service<Req></code></h3>
|
||||
<p>A <a href="../dev/trait.Service.html" title="trait actix_web::dev::Service"><code>Service</code></a> <code>S</code> represents an asynchronous operation that turns a request of type <code>Req</code> into a
|
||||
response of type <a href="../dev/trait.Service.html#associatedtype.Response" title="associated type actix_web::dev::Service::Response"><code>S::Response</code></a> or an error of type
|
||||
<a href="../dev/trait.Service.html#associatedtype.Error" title="associated type actix_web::dev::Service::Error"><code>S::Error</code></a>. You can think of the service of being roughly:</p>
|
||||
|
||||
<div class="example-wrap ignore"><a href="#" class="tooltip" title="This example is not tested">ⓘ</a><pre class="rust rust-example-rendered"><code><span class="kw">async fn</span>(<span class="kw-2">&</span><span class="self">self</span>, req: Req) -> <span class="prelude-ty">Result</span><S::Response, S::Error></code></pre></div>
|
||||
<p>In most cases the <a href="../dev/trait.Service.html" title="trait actix_web::dev::Service"><code>Service</code></a> implementation will, at some point, call the wrapped <a href="../dev/trait.Service.html" title="trait actix_web::dev::Service"><code>Service</code></a>
|
||||
in its <a href="../dev/trait.Service.html#tymethod.call" title="method actix_web::dev::Service::call"><code>call</code></a> implementation.</p>
|
||||
<p>Note that the <a href="../dev/trait.Service.html" title="trait actix_web::dev::Service"><code>Service</code></a>s created by <a href="../dev/trait.Transform.html#tymethod.new_transform" title="method actix_web::dev::Transform::new_transform"><code>new_transform</code></a> don’t need to be <a href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send"><code>Send</code></a> or <a href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync"><code>Sync</code></a>.</p>
|
||||
<h2 id="example"><a class="doc-anchor" href="#example">§</a>Example</h2>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::{future::{ready, Ready, Future}, pin::Pin};
|
||||
|
||||
<span class="kw">use </span>actix_web::{
|
||||
dev::{forward_ready, Service, ServiceRequest, ServiceResponse, Transform},
|
||||
web, Error,
|
||||
};
|
||||
|
||||
<span class="kw">pub struct </span>SayHi;
|
||||
|
||||
<span class="comment">// `S` - type of the next service
|
||||
// `B` - type of response's body
|
||||
</span><span class="kw">impl</span><S, B> Transform<S, ServiceRequest> <span class="kw">for </span>SayHi
|
||||
<span class="kw">where
|
||||
</span>S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
S::Future: <span class="lifetime">'static</span>,
|
||||
B: <span class="lifetime">'static</span>,
|
||||
{
|
||||
<span class="kw">type </span>Response = ServiceResponse<B>;
|
||||
<span class="kw">type </span>Error = Error;
|
||||
<span class="kw">type </span>InitError = ();
|
||||
<span class="kw">type </span>Transform = SayHiMiddleware<S>;
|
||||
<span class="kw">type </span>Future = Ready<<span class="prelude-ty">Result</span><<span class="self">Self</span>::Transform, <span class="self">Self</span>::InitError>>;
|
||||
|
||||
<span class="kw">fn </span>new_transform(<span class="kw-2">&</span><span class="self">self</span>, service: S) -> <span class="self">Self</span>::Future {
|
||||
ready(<span class="prelude-val">Ok</span>(SayHiMiddleware { service }))
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">pub struct </span>SayHiMiddleware<S> {
|
||||
<span class="doccomment">/// The next service to call
|
||||
</span>service: S,
|
||||
}
|
||||
|
||||
<span class="comment">// This future doesn't have the requirement of being `Send`.
|
||||
// See: futures_util::future::LocalBoxFuture
|
||||
</span><span class="kw">type </span>LocalBoxFuture<T> = Pin<Box<<span class="kw">dyn </span>Future<Output = T> + <span class="lifetime">'static</span>>>;
|
||||
|
||||
<span class="comment">// `S`: type of the wrapped service
|
||||
// `B`: type of the body - try to be generic over the body where possible
|
||||
</span><span class="kw">impl</span><S, B> Service<ServiceRequest> <span class="kw">for </span>SayHiMiddleware<S>
|
||||
<span class="kw">where
|
||||
</span>S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
S::Future: <span class="lifetime">'static</span>,
|
||||
B: <span class="lifetime">'static</span>,
|
||||
{
|
||||
<span class="kw">type </span>Response = ServiceResponse<B>;
|
||||
<span class="kw">type </span>Error = Error;
|
||||
<span class="kw">type </span>Future = LocalBoxFuture<<span class="prelude-ty">Result</span><<span class="self">Self</span>::Response, <span class="self">Self</span>::Error>>;
|
||||
|
||||
<span class="comment">// This service is ready when its next service is ready
|
||||
</span><span class="macro">forward_ready!</span>(service);
|
||||
|
||||
<span class="kw">fn </span>call(<span class="kw-2">&</span><span class="self">self</span>, req: ServiceRequest) -> <span class="self">Self</span>::Future {
|
||||
<span class="macro">println!</span>(<span class="string">"Hi from start. You requested: {}"</span>, req.path());
|
||||
|
||||
<span class="comment">// A more complex middleware, could return an error or an early response here.
|
||||
|
||||
</span><span class="kw">let </span>fut = <span class="self">self</span>.service.call(req);
|
||||
|
||||
Box::pin(<span class="kw">async move </span>{
|
||||
<span class="kw">let </span>res = fut.<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="macro">println!</span>(<span class="string">"Hi from response"</span>);
|
||||
<span class="prelude-val">Ok</span>(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">let </span>app = App::new()
|
||||
.wrap(SayHi)
|
||||
.route(<span class="string">"/"</span>, web::get().to(|| <span class="kw">async </span>{ <span class="string">"Hello, middleware!" </span>}));</code></pre></div>
|
||||
<h2 id="simpler-middleware"><a class="doc-anchor" href="#simpler-middleware">§</a>Simpler Middleware</h2>
|
||||
<p>In many cases, you <em>can</em> actually use an async function via a helper that will provide a more
|
||||
natural flow for your behavior.</p>
|
||||
<p>The experimental <code>actix_web_lab</code> crate provides a <a href="https://docs.rs/actix-web-lab/latest/actix_web_lab/middleware/fn.from_fn.html"><code>from_fn</code></a> utility which allows
|
||||
an async fn to be wrapped and used in the same way as other middleware. See the
|
||||
<a href="https://docs.rs/actix-web-lab/latest/actix_web_lab/middleware/fn.from_fn.html"><code>from_fn</code></a> docs for more info and examples of it’s use.</p>
|
||||
<p>While <a href="https://docs.rs/actix-web-lab/latest/actix_web_lab/middleware/fn.from_fn.html"><code>from_fn</code></a> is experimental currently, it’s likely this helper will graduate
|
||||
to Actix Web in some form, so feedback is appreciated.</p>
|
||||
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Compat.html" title="struct actix_web::middleware::Compat">Compat</a></div><div class="desc docblock-short">Middleware for enabling any middleware to be used in <a href="../struct.Resource.html#method.wrap" title="method actix_web::Resource::wrap"><code>Resource::wrap</code></a>,
|
||||
and <a href="struct.Condition.html" title="struct actix_web::middleware::Condition"><code>Condition</code></a>.</div></li><li><div class="item-name"><a class="struct" href="struct.Compress.html" title="struct actix_web::middleware::Compress">Compress</a><span class="stab portability" title="Available on crate feature `__compress` only"><code>__compress</code></span></div><div class="desc docblock-short">Middleware for compressing response payloads.</div></li><li><div class="item-name"><a class="struct" href="struct.Condition.html" title="struct actix_web::middleware::Condition">Condition</a></div><div class="desc docblock-short">Middleware for conditionally enabling other middleware.</div></li><li><div class="item-name"><a class="struct" href="struct.DefaultHeaders.html" title="struct actix_web::middleware::DefaultHeaders">DefaultHeaders</a></div><div class="desc docblock-short">Middleware for setting default response headers.</div></li><li><div class="item-name"><a class="struct" href="struct.ErrorHandlers.html" title="struct actix_web::middleware::ErrorHandlers">ErrorHandlers</a></div><div class="desc docblock-short">Middleware for registering custom status code based error handlers.</div></li><li><div class="item-name"><a class="struct" href="struct.Logger.html" title="struct actix_web::middleware::Logger">Logger</a></div><div class="desc docblock-short">Middleware for logging request and response summaries to the terminal.</div></li><li><div class="item-name"><a class="struct" href="struct.NormalizePath.html" title="struct actix_web::middleware::NormalizePath">NormalizePath</a></div><div class="desc docblock-short">Middleware for normalizing a request’s path so that routes can be matched more flexibly.</div></li></ul><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="enum" href="enum.ErrorHandlerResponse.html" title="enum actix_web::middleware::ErrorHandlerResponse">ErrorHandlerResponse</a></div><div class="desc docblock-short">Return type for <a href="struct.ErrorHandlers.html" title="struct actix_web::middleware::ErrorHandlers"><code>ErrorHandlers</code></a> custom handlers.</div></li><li><div class="item-name"><a class="enum" href="enum.TrailingSlash.html" title="enum actix_web::middleware::TrailingSlash">TrailingSlash</a></div><div class="desc docblock-short">Determines the behavior of the <a href="struct.NormalizePath.html" title="struct actix_web::middleware::NormalizePath"><code>NormalizePath</code></a> middleware.</div></li></ul></section></div></main></body></html>
|
11
actix_web/middleware/logger/struct.Logger.html
Normal file
11
actix_web/middleware/logger/struct.Logger.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../actix_web/middleware/struct.Logger.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../actix_web/middleware/struct.Logger.html">../../../actix_web/middleware/struct.Logger.html</a>...</p>
|
||||
<script>location.replace("../../../actix_web/middleware/struct.Logger.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
11
actix_web/middleware/normalize/enum.TrailingSlash.html
Normal file
11
actix_web/middleware/normalize/enum.TrailingSlash.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../actix_web/middleware/enum.TrailingSlash.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../actix_web/middleware/enum.TrailingSlash.html">../../../actix_web/middleware/enum.TrailingSlash.html</a>...</p>
|
||||
<script>location.replace("../../../actix_web/middleware/enum.TrailingSlash.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
11
actix_web/middleware/normalize/struct.NormalizePath.html
Normal file
11
actix_web/middleware/normalize/struct.NormalizePath.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../actix_web/middleware/struct.NormalizePath.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../actix_web/middleware/struct.NormalizePath.html">../../../actix_web/middleware/struct.NormalizePath.html</a>...</p>
|
||||
<script>location.replace("../../../actix_web/middleware/struct.NormalizePath.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
1
actix_web/middleware/sidebar-items.js
Normal file
1
actix_web/middleware/sidebar-items.js
Normal file
@ -0,0 +1 @@
|
||||
window.SIDEBAR_ITEMS = {"enum":["ErrorHandlerResponse","TrailingSlash"],"struct":["Compat","Compress","Condition","DefaultHeaders","ErrorHandlers","Logger","NormalizePath"]};
|
44
actix_web/middleware/struct.Compat.html
Normal file
44
actix_web/middleware/struct.Compat.html
Normal file
File diff suppressed because one or more lines are too long
57
actix_web/middleware/struct.Compress.html
Normal file
57
actix_web/middleware/struct.Compress.html
Normal file
File diff suppressed because one or more lines are too long
36
actix_web/middleware/struct.Condition.html
Normal file
36
actix_web/middleware/struct.Condition.html
Normal file
File diff suppressed because one or more lines are too long
38
actix_web/middleware/struct.DefaultHeaders.html
Normal file
38
actix_web/middleware/struct.DefaultHeaders.html
Normal file
File diff suppressed because one or more lines are too long
139
actix_web/middleware/struct.ErrorHandlers.html
Normal file
139
actix_web/middleware/struct.ErrorHandlers.html
Normal file
File diff suppressed because one or more lines are too long
104
actix_web/middleware/struct.Logger.html
Normal file
104
actix_web/middleware/struct.Logger.html
Normal file
File diff suppressed because one or more lines are too long
64
actix_web/middleware/struct.NormalizePath.html
Normal file
64
actix_web/middleware/struct.NormalizePath.html
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user