1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-06-12 02:09:36 +00:00
actix-web/actix_web/trait.Responder.html
2024-05-27 01:16:31 +00:00

62 lines
43 KiB
HTML

<!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="Trait implemented by types that can be converted to an HTTP response."><title>Responder in actix_web - 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 trait"><!--[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="#">Responder</a></h2><div class="sidebar-elems"><section><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Body">Body</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.respond_to">respond_to</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.customize">customize</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-Responder-for-%26%5Bu8%5D">&amp;&#x27;static [u8]</a></li><li><a href="#impl-Responder-for-%26str">&amp;&#x27;static str</a></li><li><a href="#impl-Responder-for-%26String">&amp;String</a></li><li><a href="#impl-Responder-for-(R,+StatusCode)">(R, StatusCode)</a></li><li><a href="#impl-Responder-for-ByteString">ByteString</a></li><li><a href="#impl-Responder-for-Cow%3C'_,+str%3E">Cow&lt;&#x27;_, str&gt;</a></li><li><a href="#impl-Responder-for-Option%3CR%3E">Option&lt;R&gt;</a></li><li><a href="#impl-Responder-for-ResponseBuilder">ResponseBuilder</a></li><li><a href="#impl-Responder-for-Result%3CR,+E%3E">Result&lt;R, E&gt;</a></li><li><a href="#impl-Responder-for-String">String</a></li><li><a href="#impl-Responder-for-Vec%3Cu8%3E">Vec&lt;u8&gt;</a></li></ul><h3><a href="#implementors">Implementors</a></h3></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>Trait <a href="index.html">actix_web</a>::<wbr><a class="trait" href="#">Responder</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/response/responder.rs.html#39-88">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><pre class="rust item-decl"><code>pub trait Responder {
type <a href="#associatedtype.Body" class="associatedtype">Body</a>: <a class="trait" href="body/trait.MessageBody.html" title="trait actix_web::body::MessageBody">MessageBody</a> + 'static;
// Required method
fn <a href="#tymethod.respond_to" class="fn">respond_to</a>(self, req: &amp;<a class="struct" href="struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a>) -&gt; <a class="struct" href="struct.HttpResponse.html" title="struct actix_web::HttpResponse">HttpResponse</a>&lt;Self::<a class="associatedtype" href="trait.Responder.html#associatedtype.Body" title="type actix_web::Responder::Body">Body</a>&gt;;
// Provided method
fn <a href="#method.customize" class="fn">customize</a>(self) -&gt; <a class="struct" href="struct.CustomizeResponder.html" title="struct actix_web::CustomizeResponder">CustomizeResponder</a>&lt;Self&gt;
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Trait implemented by types that can be converted to an HTTP response.</p>
<p>Any types that implement this trait can be used in the return type of a handler. Since handlers
will only have one return type, it is idiomatic to use opaque return types <code>-&gt; impl Responder</code>.</p>
<h2 id="implementations-1"><a class="doc-anchor" href="#implementations-1">§</a>Implementations</h2>
<p>It is often not required to implement <code>Responder</code> for your own types due to a broad base of
built-in implementations:</p>
<ul>
<li><code>HttpResponse</code> and <code>HttpResponseBuilder</code></li>
<li><code>Option&lt;R&gt;</code> where <code>R: Responder</code></li>
<li><code>Result&lt;R, E&gt;</code> where <code>R: Responder</code> and <a href="error/trait.ResponseError.html" title="trait actix_web::error::ResponseError"><code>E: ResponseError</code></a></li>
<li><code>(R, StatusCode)</code> where <code>R: Responder</code></li>
<li><code>&amp;'static str</code>, <code>String</code>, <code>&amp;'_ String</code>, <code>Cow&lt;'_, str&gt;</code>, <a href="bytestring::ByteString"><code>ByteString</code></a></li>
<li><code>&amp;'static [u8]</code>, <code>Vec&lt;u8&gt;</code>, <code>Bytes</code>, <code>BytesMut</code></li>
<li><a href="web/struct.Json.html" title="struct actix_web::web::Json"><code>Json&lt;T&gt;</code></a> and <a href="web/struct.Form.html" title="struct actix_web::web::Form"><code>Form&lt;T&gt;</code></a> where <code>T: Serialize</code></li>
<li><a href="web/enum.Either.html" title="enum actix_web::web::Either"><code>Either&lt;L, R&gt;</code></a> where <code>L: Serialize</code> and <code>R: Serialize</code></li>
<li><a href="struct.CustomizeResponder.html" title="struct actix_web::CustomizeResponder"><code>CustomizeResponder&lt;R&gt;</code></a></li>
<li><a href="https://docs.rs/actix-files/latest/actix_files/struct.NamedFile.html"><code>actix_files::NamedFile</code></a></li>
<li><a href="https://docs.rs/actix-web-lab/latest/actix_web_lab/respond/index.html">Experimental responders from <code>actix-web-lab</code></a></li>
<li>Third party integrations may also have implemented <code>Responder</code> where appropriate. For example,
HTML templating engines.</li>
</ul>
<h2 id="customizing-responder-output"><a class="doc-anchor" href="#customizing-responder-output">§</a>Customizing Responder Output</h2>
<p>Calling <a href="trait.Responder.html#method.customize" title="method actix_web::Responder::customize"><code>.customize()</code></a> on any responder type will wrap it in a
<a href="struct.CustomizeResponder.html" title="struct actix_web::CustomizeResponder"><code>CustomizeResponder</code></a> capable of overriding various parts of the response such as the status
code and header map.</p>
</div></details><h2 id="required-associated-types" class="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><section id="associatedtype.Body" class="method"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#40">source</a><h4 class="code-header">type <a href="#associatedtype.Body" class="associatedtype">Body</a>: <a class="trait" href="body/trait.MessageBody.html" title="trait actix_web::body::MessageBody">MessageBody</a> + 'static</h4></section></div><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.respond_to" class="method"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#43">source</a><h4 class="code-header">fn <a href="#tymethod.respond_to" class="fn">respond_to</a>(self, req: &amp;<a class="struct" href="struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a>) -&gt; <a class="struct" href="struct.HttpResponse.html" title="struct actix_web::HttpResponse">HttpResponse</a>&lt;Self::<a class="associatedtype" href="trait.Responder.html#associatedtype.Body" title="type actix_web::Responder::Body">Body</a>&gt;</h4></section></summary><div class="docblock"><p>Convert self to <code>HttpResponse</code>.</p>
</div></details></div><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.customize" class="method"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#64-69">source</a><h4 class="code-header">fn <a href="#method.customize" class="fn">customize</a>(self) -&gt; <a class="struct" href="struct.CustomizeResponder.html" title="struct actix_web::CustomizeResponder">CustomizeResponder</a>&lt;Self&gt;<div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Wraps responder to allow alteration of its response.</p>
<p>See <a href="struct.CustomizeResponder.html" title="struct actix_web::CustomizeResponder"><code>CustomizeResponder</code></a> docs for more details on its capabilities.</p>
<h5 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>actix_web::{Responder, http::StatusCode, test::TestRequest};
<span class="kw">let </span>responder = <span class="string">"Hello world!"
</span>.customize()
.with_status(StatusCode::BAD_REQUEST)
.insert_header((<span class="string">"x-hello"</span>, <span class="string">"world"</span>));
<span class="kw">let </span>request = TestRequest::default().to_http_request();
<span class="kw">let </span>response = responder.respond_to(<span class="kw-2">&amp;</span>request);
<span class="macro">assert_eq!</span>(response.status(), StatusCode::BAD_REQUEST);
<span class="macro">assert_eq!</span>(response.headers().get(<span class="string">"x-hello"</span>).unwrap(), <span class="string">"world"</span>);</code></pre></div>
</div></details></div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-Responder-for-%26str" class="impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#166">source</a><a href="#impl-Responder-for-%26str" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> for &amp;'static <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Body-1" class="associatedtype trait-impl"><a href="#associatedtype.Body-1" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Body" class="associatedtype">Body</a> = &amp;'static <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></h4></section><section id="method.respond_to" class="method trait-impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#166">source</a><a href="#method.respond_to" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.respond_to" class="fn">respond_to</a>(self, _: &amp;<a class="struct" href="struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a>) -&gt; <a class="struct" href="struct.HttpResponse.html" title="struct actix_web::HttpResponse">HttpResponse</a>&lt;Self::<a class="associatedtype" href="trait.Responder.html#associatedtype.Body" title="type actix_web::Responder::Body">Body</a>&gt;</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Responder-for-%26%5Bu8%5D" class="impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#161">source</a><a href="#impl-Responder-for-%26%5Bu8%5D" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> for &amp;'static [<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]</h3></section></summary><div class="impl-items"><section id="associatedtype.Body-2" class="associatedtype trait-impl"><a href="#associatedtype.Body-2" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Body" class="associatedtype">Body</a> = &amp;'static [<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]</h4></section><section id="method.respond_to-1" class="method trait-impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#161">source</a><a href="#method.respond_to-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.respond_to" class="fn">respond_to</a>(self, _: &amp;<a class="struct" href="struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a>) -&gt; <a class="struct" href="struct.HttpResponse.html" title="struct actix_web::HttpResponse">HttpResponse</a>&lt;Self::<a class="associatedtype" href="trait.Responder.html#associatedtype.Body" title="type actix_web::Responder::Body">Body</a>&gt;</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Responder-for-%26String" class="impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#184">source</a><a href="#impl-Responder-for-%26String" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> for &amp;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Body-3" class="associatedtype trait-impl"><a href="#associatedtype.Body-3" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Body" class="associatedtype">Body</a> = <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></h4></section><section id="method.respond_to-2" class="method trait-impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#184">source</a><a href="#method.respond_to-2" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.respond_to" class="fn">respond_to</a>(self, _: &amp;<a class="struct" href="struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a>) -&gt; <a class="struct" href="struct.HttpResponse.html" title="struct actix_web::HttpResponse">HttpResponse</a>&lt;Self::<a class="associatedtype" href="trait.Responder.html#associatedtype.Body" title="type actix_web::Responder::Body">Body</a>&gt;</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Responder-for-Cow%3C'_,+str%3E" class="impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#185">source</a><a href="#impl-Responder-for-Cow%3C'_,+str%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> for <a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a>&lt;'_, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;</h3></section></summary><div class="impl-items"><section id="associatedtype.Body-4" class="associatedtype trait-impl"><a href="#associatedtype.Body-4" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Body" class="associatedtype">Body</a> = <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></h4></section><section id="method.respond_to-3" class="method trait-impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#185">source</a><a href="#method.respond_to-3" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.respond_to" class="fn">respond_to</a>(self, _: &amp;<a class="struct" href="struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a>) -&gt; <a class="struct" href="struct.HttpResponse.html" title="struct actix_web::HttpResponse">HttpResponse</a>&lt;Self::<a class="associatedtype" href="trait.Responder.html#associatedtype.Body" title="type actix_web::Responder::Body">Body</a>&gt;</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Responder-for-ResponseBuilder" class="impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#99-106">source</a><a href="#impl-Responder-for-ResponseBuilder" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> for <a class="struct" href="../actix_http/responses/builder/struct.ResponseBuilder.html" title="struct actix_http::responses::builder::ResponseBuilder">ResponseBuilder</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Body-5" class="associatedtype trait-impl"><a href="#associatedtype.Body-5" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Body" class="associatedtype">Body</a> = <a class="struct" href="body/struct.BoxBody.html" title="struct actix_web::body::BoxBody">BoxBody</a></h4></section><section id="method.respond_to-4" class="method trait-impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#103-105">source</a><a href="#method.respond_to-4" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.respond_to" class="fn">respond_to</a>(self, req: &amp;<a class="struct" href="struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a>) -&gt; <a class="struct" href="struct.HttpResponse.html" title="struct actix_web::HttpResponse">HttpResponse</a>&lt;Self::<a class="associatedtype" href="trait.Responder.html#associatedtype.Body" title="type actix_web::Responder::Body">Body</a>&gt;</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Responder-for-String" class="impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#167">source</a><a href="#impl-Responder-for-String" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Body-6" class="associatedtype trait-impl"><a href="#associatedtype.Body-6" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Body" class="associatedtype">Body</a> = <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></h4></section><section id="method.respond_to-5" class="method trait-impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#167">source</a><a href="#method.respond_to-5" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.respond_to" class="fn">respond_to</a>(self, _: &amp;<a class="struct" href="struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a>) -&gt; <a class="struct" href="struct.HttpResponse.html" title="struct actix_web::HttpResponse">HttpResponse</a>&lt;Self::<a class="associatedtype" href="trait.Responder.html#associatedtype.Body" title="type actix_web::Responder::Body">Body</a>&gt;</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Responder-for-Vec%3Cu8%3E" class="impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#162">source</a><a href="#impl-Responder-for-Vec%3Cu8%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;</h3></section></summary><div class="impl-items"><section id="associatedtype.Body-7" class="associatedtype trait-impl"><a href="#associatedtype.Body-7" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Body" class="associatedtype">Body</a> = <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;</h4></section><section id="method.respond_to-6" class="method trait-impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#162">source</a><a href="#method.respond_to-6" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.respond_to" class="fn">respond_to</a>(self, _: &amp;<a class="struct" href="struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a>) -&gt; <a class="struct" href="struct.HttpResponse.html" title="struct actix_web::HttpResponse">HttpResponse</a>&lt;Self::<a class="associatedtype" href="trait.Responder.html#associatedtype.Body" title="type actix_web::Responder::Body">Body</a>&gt;</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Responder-for-ByteString" class="impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#168">source</a><a href="#impl-Responder-for-ByteString" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> for ByteString</h3></section></summary><div class="impl-items"><section id="associatedtype.Body-8" class="associatedtype trait-impl"><a href="#associatedtype.Body-8" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Body" class="associatedtype">Body</a> = ByteString</h4></section><section id="method.respond_to-7" class="method trait-impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#168">source</a><a href="#method.respond_to-7" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.respond_to" class="fn">respond_to</a>(self, _: &amp;<a class="struct" href="struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a>) -&gt; <a class="struct" href="struct.HttpResponse.html" title="struct actix_web::HttpResponse">HttpResponse</a>&lt;Self::<a class="associatedtype" href="trait.Responder.html#associatedtype.Body" title="type actix_web::Responder::Body">Body</a>&gt;</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Responder-for-Result%3CR,+E%3E" class="impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#119-132">source</a><a href="#impl-Responder-for-Result%3CR,+E%3E" class="anchor">§</a><h3 class="code-header">impl&lt;R, E&gt; <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> for <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;R, E&gt;<div class="where">where
R: <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a>,
E: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="struct" href="error/struct.Error.html" title="struct actix_web::error::Error">Error</a>&gt;,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Body-9" class="associatedtype trait-impl"><a href="#associatedtype.Body-9" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Body" class="associatedtype">Body</a> = <a class="enum" href="body/enum.EitherBody.html" title="enum actix_web::body::EitherBody">EitherBody</a>&lt;&lt;R as <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a>&gt;::<a class="associatedtype" href="trait.Responder.html#associatedtype.Body" title="type actix_web::Responder::Body">Body</a>&gt;</h4></section><section id="method.respond_to-8" class="method trait-impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#126-131">source</a><a href="#method.respond_to-8" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.respond_to" class="fn">respond_to</a>(self, req: &amp;<a class="struct" href="struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a>) -&gt; <a class="struct" href="struct.HttpResponse.html" title="struct actix_web::HttpResponse">HttpResponse</a>&lt;Self::<a class="associatedtype" href="trait.Responder.html#associatedtype.Body" title="type actix_web::Responder::Body">Body</a>&gt;</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Responder-for-(R,+StatusCode)" class="impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#134-142">source</a><a href="#impl-Responder-for-(R,+StatusCode)" class="anchor">§</a><h3 class="code-header">impl&lt;R: <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a>&gt; <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> for (R, <a class="struct" href="http/struct.StatusCode.html" title="struct actix_web::http::StatusCode">StatusCode</a>)</h3></section></summary><div class="impl-items"><section id="associatedtype.Body-10" class="associatedtype trait-impl"><a href="#associatedtype.Body-10" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Body" class="associatedtype">Body</a> = &lt;R as <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a>&gt;::<a class="associatedtype" href="trait.Responder.html#associatedtype.Body" title="type actix_web::Responder::Body">Body</a></h4></section><section id="method.respond_to-9" class="method trait-impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#137-141">source</a><a href="#method.respond_to-9" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.respond_to" class="fn">respond_to</a>(self, req: &amp;<a class="struct" href="struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a>) -&gt; <a class="struct" href="struct.HttpResponse.html" title="struct actix_web::HttpResponse">HttpResponse</a>&lt;Self::<a class="associatedtype" href="trait.Responder.html#associatedtype.Body" title="type actix_web::Responder::Body">Body</a>&gt;</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Responder-for-Option%3CR%3E" class="impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#108-117">source</a><a href="#impl-Responder-for-Option%3CR%3E" class="anchor">§</a><h3 class="code-header">impl&lt;R: <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a>&gt; <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> for <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;R&gt;</h3></section></summary><div class="impl-items"><section id="associatedtype.Body-11" class="associatedtype trait-impl"><a href="#associatedtype.Body-11" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Body" class="associatedtype">Body</a> = <a class="enum" href="body/enum.EitherBody.html" title="enum actix_web::body::EitherBody">EitherBody</a>&lt;&lt;R as <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a>&gt;::<a class="associatedtype" href="trait.Responder.html#associatedtype.Body" title="type actix_web::Responder::Body">Body</a>&gt;</h4></section><section id="method.respond_to-10" class="method trait-impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#111-116">source</a><a href="#method.respond_to-10" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.respond_to" class="fn">respond_to</a>(self, req: &amp;<a class="struct" href="struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a>) -&gt; <a class="struct" href="struct.HttpResponse.html" title="struct actix_web::HttpResponse">HttpResponse</a>&lt;Self::<a class="associatedtype" href="trait.Responder.html#associatedtype.Body" title="type actix_web::Responder::Body">Body</a>&gt;</h4></section></div></details><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><details class="toggle implementors-toggle"><summary><section id="impl-Responder-for-Response%3CBoxBody%3E" class="impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#90-97">source</a><a href="#impl-Responder-for-Response%3CBoxBody%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> for <a class="struct" href="dev/struct.Response.html" title="struct actix_web::dev::Response">Response</a>&lt;<a class="struct" href="body/struct.BoxBody.html" title="struct actix_web::body::BoxBody">BoxBody</a>&gt;</h3></section></summary><div class="impl-items"><section id="associatedtype.Body-12" class="associatedtype trait-impl"><a href="#associatedtype.Body-12" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Body" class="associatedtype">Body</a> = <a class="struct" href="body/struct.BoxBody.html" title="struct actix_web::body::BoxBody">BoxBody</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Responder-for-HttpResponseBuilder" class="impl"><a class="src rightside" href="../src/actix_web/response/builder.rs.html#397-404">source</a><a href="#impl-Responder-for-HttpResponseBuilder" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> for <a class="struct" href="struct.HttpResponseBuilder.html" title="struct actix_web::HttpResponseBuilder">HttpResponseBuilder</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Body-13" class="associatedtype trait-impl"><a href="#associatedtype.Body-13" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Body" class="associatedtype">Body</a> = <a class="struct" href="body/struct.BoxBody.html" title="struct actix_web::body::BoxBody">BoxBody</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Responder-for-Bytes" class="impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#163">source</a><a href="#impl-Responder-for-Bytes" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> for <a class="struct" href="web/struct.Bytes.html" title="struct actix_web::web::Bytes">Bytes</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Body-14" class="associatedtype trait-impl"><a href="#associatedtype.Body-14" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Body" class="associatedtype">Body</a> = <a class="struct" href="web/struct.Bytes.html" title="struct actix_web::web::Bytes">Bytes</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Responder-for-BytesMut" class="impl"><a class="src rightside" href="../src/actix_web/response/responder.rs.html#164">source</a><a href="#impl-Responder-for-BytesMut" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> for <a class="struct" href="web/struct.BytesMut.html" title="struct actix_web::web::BytesMut">BytesMut</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Body-15" class="associatedtype trait-impl"><a href="#associatedtype.Body-15" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Body" class="associatedtype">Body</a> = <a class="struct" href="web/struct.BytesMut.html" title="struct actix_web::web::BytesMut">BytesMut</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Responder-for-Redirect" class="impl"><a class="src rightside" href="../src/actix_web/redirect.rs.html#163-180">source</a><a href="#impl-Responder-for-Redirect" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> for <a class="struct" href="web/struct.Redirect.html" title="struct actix_web::web::Redirect">Redirect</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Body-16" class="associatedtype trait-impl"><a href="#associatedtype.Body-16" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Body" class="associatedtype">Body</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Responder-for-HttpResponse%3CB%3E" class="impl"><a class="src rightside" href="../src/actix_web/response/response.rs.html#365-375">source</a><a href="#impl-Responder-for-HttpResponse%3CB%3E" class="anchor">§</a><h3 class="code-header">impl&lt;B&gt; <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> for <a class="struct" href="struct.HttpResponse.html" title="struct actix_web::HttpResponse">HttpResponse</a>&lt;B&gt;<div class="where">where
B: <a class="trait" href="body/trait.MessageBody.html" title="trait actix_web::body::MessageBody">MessageBody</a> + 'static,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Body-17" class="associatedtype trait-impl"><a href="#associatedtype.Body-17" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Body" class="associatedtype">Body</a> = B</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Responder-for-Either%3CL,+R%3E" class="impl"><a class="src rightside" href="../src/actix_web/types/either.rs.html#125-138">source</a><a href="#impl-Responder-for-Either%3CL,+R%3E" class="anchor">§</a><h3 class="code-header">impl&lt;L, R&gt; <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> for <a class="enum" href="web/enum.Either.html" title="enum actix_web::web::Either">Either</a>&lt;L, R&gt;<div class="where">where
L: <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a>,
R: <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a>,</div></h3></section></summary><div class="docblock"><p>See <a href="#responder">here</a> for example of usage as a handler return type.</p>
</div><div class="impl-items"><section id="associatedtype.Body-18" class="associatedtype trait-impl"><a href="#associatedtype.Body-18" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Body" class="associatedtype">Body</a> = <a class="enum" href="body/enum.EitherBody.html" title="enum actix_web::body::EitherBody">EitherBody</a>&lt;&lt;L as <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a>&gt;::<a class="associatedtype" href="trait.Responder.html#associatedtype.Body" title="type actix_web::Responder::Body">Body</a>, &lt;R as <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a>&gt;::<a class="associatedtype" href="trait.Responder.html#associatedtype.Body" title="type actix_web::Responder::Body">Body</a>&gt;</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Responder-for-InternalError%3CT%3E" class="impl"><a class="src rightside" href="../src/actix_web/error/internal.rs.html#108-117">source</a><a href="#impl-Responder-for-InternalError%3CT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> for <a class="struct" href="error/struct.InternalError.html" title="struct actix_web::error::InternalError">InternalError</a>&lt;T&gt;<div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> + 'static,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Body-19" class="associatedtype trait-impl"><a href="#associatedtype.Body-19" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Body" class="associatedtype">Body</a> = <a class="struct" href="body/struct.BoxBody.html" title="struct actix_web::body::BoxBody">BoxBody</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Responder-for-CustomizeResponder%3CT%3E" class="impl"><a class="src rightside" href="../src/actix_web/response/customize_responder.rs.html#142-169">source</a><a href="#impl-Responder-for-CustomizeResponder%3CT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> for <a class="struct" href="struct.CustomizeResponder.html" title="struct actix_web::CustomizeResponder">CustomizeResponder</a>&lt;T&gt;<div class="where">where
T: <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Body-20" class="associatedtype trait-impl"><a href="#associatedtype.Body-20" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Body" class="associatedtype">Body</a> = <a class="enum" href="body/enum.EitherBody.html" title="enum actix_web::body::EitherBody">EitherBody</a>&lt;&lt;T as <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a>&gt;::<a class="associatedtype" href="trait.Responder.html#associatedtype.Body" title="type actix_web::Responder::Body">Body</a>&gt;</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Responder-for-Form%3CT%3E" class="impl"><a class="src rightside" href="../src/actix_web/types/form.rs.html#181-199">source</a><a href="#impl-Responder-for-Form%3CT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;T: <a class="trait" href="https://docs.rs/serde/1.0.203/serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a>&gt; <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> for <a class="struct" href="web/struct.Form.html" title="struct actix_web::web::Form">Form</a>&lt;T&gt;</h3></section></summary><div class="docblock"><p>See <a href="#responder">here</a> for example of usage as a handler return type.</p>
</div><div class="impl-items"><section id="associatedtype.Body-21" class="associatedtype trait-impl"><a href="#associatedtype.Body-21" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Body" class="associatedtype">Body</a> = <a class="enum" href="body/enum.EitherBody.html" title="enum actix_web::body::EitherBody">EitherBody</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Responder-for-Json%3CT%3E" class="impl"><a class="src rightside" href="../src/actix_web/types/json.rs.html#118-136">source</a><a href="#impl-Responder-for-Json%3CT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;T: <a class="trait" href="https://docs.rs/serde/1.0.203/serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a>&gt; <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> for <a class="struct" href="web/struct.Json.html" title="struct actix_web::web::Json">Json</a>&lt;T&gt;</h3></section></summary><div class="docblock"><p>Creates response with OK status code, correct content type header, and serialized JSON payload.</p>
<p>If serialization failed</p>
</div><div class="impl-items"><section id="associatedtype.Body-22" class="associatedtype trait-impl"><a href="#associatedtype.Body-22" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Body" class="associatedtype">Body</a> = <a class="enum" href="body/enum.EitherBody.html" title="enum actix_web::body::EitherBody">EitherBody</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;</h4></section></div></details></div><script src="../trait.impl/actix_web/response/responder/trait.Responder.js" data-ignore-extern-crates="alloc,core,bytes,actix_http,std,bytestring" async></script></section></div></main></body></html>