<main><divclass="width-limiter"><navclass="sub"><formclass="search-form"><span></span><divid="sidebar-button"tabindex="-1"><ahref="../actix_cors/all.html"title="show sidebar"></a></div><inputclass="search-input"name="search"aria-label="Run search in the documentation"autocomplete="off"spellcheck="false"placeholder="Click or press ‘S’ to search, ‘?’ for more options…"type="search"><divid="help-button"tabindex="-1"><ahref="../help.html"title="help">?</a></div><divid="settings-menu"tabindex="-1"><ahref="../settings.html"title="settings"><imgwidth="22"height="22"alt="Change settings"src="../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><sectionid="main-content"class="content"><divclass="main-heading"><h1>Struct <ahref="index.html">actix_cors</a>::<wbr><aclass="struct"href="#">Cors</a><buttonid="copy-path"title="Copy item path to clipboard"><imgsrc="../static.files/clipboard-7571035ce49a181d.svg"width="19"height="18"alt="Copy item path"></button></h1><spanclass="out-of-band"><aclass="src"href="../src/actix_cors/builder.rs.html#86-89">source</a> · <buttonid="toggle-all-docs"title="collapse all docs">[<span>−</span>]</button></span></div><preclass="rust item-decl"><code>pub struct Cors { <spanclass="comment">/* private fields */</span> }</code></pre><detailsclass="toggle top-doc"open><summaryclass="hideme"><span>Expand description</span></summary><divclass="docblock"><p>Builder for CORS middleware.</p>
<p>To construct a CORS middleware, call <ahref="struct.Cors.html#method.default"title="associated function actix_cors::Cors::default"><code>Cors::default()</code></a> to create a blank, restrictive builder.
<p>The alternative <ahref="struct.Cors.html#method.permissive"title="associated function actix_cors::Cors::permissive"><code>Cors::permissive()</code></a> constructor is available for local development, allowing
<p>In all cases, behavior for this crate follows the <ahref="https://fetch.spec.whatwg.org/#http-cors-protocol">Fetch Standard CORS protocol</a>. See that
document for information on exact semantics for configuration options and combinations.</p>
</div></details><h2id="implementations"class="section-header">Implementations<ahref="#implementations"class="anchor">§</a></h2><divid="implementations-list"><detailsclass="toggle implementors-toggle"open><summary><sectionid="impl-Cors"class="impl"><aclass="src rightside"href="../src/actix_cors/builder.rs.html#91-488">source</a><ahref="#impl-Cors"class="anchor">§</a><h3class="code-header">impl <aclass="struct"href="struct.Cors.html"title="struct actix_cors::Cors">Cors</a></h3></section></summary><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.permissive"class="method"><aclass="src rightside"href="../src/actix_cors/builder.rs.html#97-125">source</a><h4class="code-header">pub fn <ahref="#method.permissive"class="fn">permissive</a>() -> Self</h4></section></summary><divclass="docblock"><p>Constructs a very permissive set of defaults for quick development. (Not recommended for
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.allow_any_origin"class="method"><aclass="src rightside"href="../src/actix_cors/builder.rs.html#130-136">source</a><h4class="code-header">pub fn <ahref="#method.allow_any_origin"class="fn">allow_any_origin</a>(self) -><aclass="struct"href="struct.Cors.html"title="struct actix_cors::Cors">Cors</a></h4></section></summary><divclass="docblock"><p>Resets allowed origin list to a state where any origin is accepted.</p>
<p>See <ahref="struct.Cors.html#method.allowed_origin"title="method actix_cors::Cors::allowed_origin"><code>Cors::allowed_origin</code></a> for more info on allowed origins.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.allowed_origin"class="method"><aclass="src rightside"href="../src/actix_cors/builder.rs.html#162-189">source</a><h4class="code-header">pub fn <ahref="#method.allowed_origin"class="fn">allowed_origin</a>(self, origin: &<aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -><aclass="struct"href="struct.Cors.html"title="struct actix_cors::Cors">Cors</a></h4></section></summary><divclass="docblock"><p>Adds an origin that is allowed to make requests.</p>
<li>If supplied origin is a wildcard (<code>*</code>). <ahref="struct.Cors.html#method.send_wildcard"title="method actix_cors::Cors::send_wildcard"><code>Cors::send_wildcard</code></a> should be used instead.</li>
F: <aclass="trait"href="https://doc.rust-lang.org/nightly/core/ops/function/trait.Fn.html"title="trait core::ops::function::Fn">Fn</a>(&<aclass="struct"href="https://docs.rs/http/0.2.11/http/header/value/struct.HeaderValue.html"title="struct http::header::value::HeaderValue">HeaderValue</a>, &RequestHead) -><aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a> + 'static,</div></h4></section></summary><divclass="docblock"><p>Determinates allowed origins by processing requests which didn’t match any origins specified
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.allow_any_method"class="method"><aclass="src rightside"href="../src/actix_cors/builder.rs.html#215-221">source</a><h4class="code-header">pub fn <ahref="#method.allow_any_method"class="fn">allow_any_method</a>(self) -><aclass="struct"href="struct.Cors.html"title="struct actix_cors::Cors">Cors</a></h4></section></summary><divclass="docblock"><p>Resets allowed methods list to all methods.</p>
<p>See <ahref="struct.Cors.html#method.allowed_methods"title="method actix_cors::Cors::allowed_methods"><code>Cors::allowed_methods</code></a> for more info on allowed methods.</p>
<M as <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html"title="trait core::convert::TryInto">TryInto</a><<aclass="struct"href="https://docs.rs/http/0.2.11/http/method/struct.Method.html"title="struct http::method::Method">Method</a>>>::<aclass="associatedtype"href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error"title="type core::convert::TryInto::Error">Error</a>: <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html"title="trait core::convert::Into">Into</a><<aclass="struct"href="https://docs.rs/http/0.2.11/http/error/struct.Error.html"title="struct http::error::Error">HttpError</a>>,</div></h4></section></summary><divclass="docblock"><p>Sets a list of methods which allowed origins can perform.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.allow_any_header"class="method"><aclass="src rightside"href="../src/actix_cors/builder.rs.html#255-261">source</a><h4class="code-header">pub fn <ahref="#method.allow_any_header"class="fn">allow_any_header</a>(self) -><aclass="struct"href="struct.Cors.html"title="struct actix_cors::Cors">Cors</a></h4></section></summary><divclass="docblock"><p>Resets allowed request header list to a state where any header is accepted.</p>
<p>See <ahref="struct.Cors.html#method.allowed_headers"title="method actix_cors::Cors::allowed_headers"><code>Cors::allowed_headers</code></a> for more info on allowed request headers.</p>
<p>See <ahref="struct.Cors.html#method.allowed_headers"title="method actix_cors::Cors::allowed_headers"><code>Cors::allowed_headers</code></a> for more info on allowed request headers.</p>
<H as <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html"title="trait core::convert::TryInto">TryInto</a><<aclass="struct"href="https://docs.rs/http/0.2.11/http/header/name/struct.HeaderName.html"title="struct http::header::name::HeaderName">HeaderName</a>>>::<aclass="associatedtype"href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error"title="type core::convert::TryInto::Error">Error</a>: <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html"title="trait core::convert::Into">Into</a><<aclass="struct"href="https://docs.rs/http/0.2.11/http/error/struct.Error.html"title="struct http::error::Error">HttpError</a>>,</div></h4></section></summary><divclass="docblock"><p>Sets a list of request header field names which can be used when this resource is accessed
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.expose_any_header"class="method"><aclass="src rightside"href="../src/actix_cors/builder.rs.html#329-335">source</a><h4class="code-header">pub fn <ahref="#method.expose_any_header"class="fn">expose_any_header</a>(self) -><aclass="struct"href="struct.Cors.html"title="struct actix_cors::Cors">Cors</a></h4></section></summary><divclass="docblock"><p>Resets exposed response header list to a state where all headers are exposed.</p>
<p>See <ahref="struct.Cors.html#method.expose_headers"title="method actix_cors::Cors::expose_headers"><code>Cors::expose_headers</code></a> for more info on exposed response headers.</p>
<H as <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html"title="trait core::convert::TryInto">TryInto</a><<aclass="struct"href="https://docs.rs/http/0.2.11/http/header/name/struct.HeaderName.html"title="struct http::header::name::HeaderName">HeaderName</a>>>::<aclass="associatedtype"href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error"title="type core::convert::TryInto::Error">Error</a>: <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html"title="trait core::convert::Into">Into</a><<aclass="struct"href="https://docs.rs/http/0.2.11/http/error/struct.Error.html"title="struct http::error::Error">HttpError</a>>,</div></h4></section></summary><divclass="docblock"><p>Sets a list of headers which are safe to expose to the API of a CORS API specification.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.max_age"class="method"><aclass="src rightside"href="../src/actix_cors/builder.rs.html#375-381">source</a><h4class="code-header">pub fn <ahref="#method.max_age"class="fn">max_age</a>(self, max_age: impl <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html"title="trait core::convert::Into">Into</a><<aclass="enum"href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>>>) -><aclass="struct"href="struct.Cors.html"title="struct actix_cors::Cors">Cors</a></h4></section></summary><divclass="docblock"><p>Sets a maximum time (in seconds) for which this CORS request may be cached.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.send_wildcard"class="method"><aclass="src rightside"href="../src/actix_cors/builder.rs.html#394-400">source</a><h4class="code-header">pub fn <ahref="#method.send_wildcard"class="fn">send_wildcard</a>(self) -><aclass="struct"href="struct.Cors.html"title="struct actix_cors::Cors">Cors</a></h4></section></summary><divclass="docblock"><p>Configures use of wildcard (<code>*</code>) origin in responses when appropriate.</p>
<p>This option <strong>CANNOT</strong> be used in conjunction with a <ahref="struct.Cors.html#method.supports_credentials"title="method actix_cors::Cors::supports_credentials">credential
supported</a> configuration. Doing so will result in an error
cookies and credentials to be submitted across domains.</p>
<p>This option <strong>CANNOT</strong> be used in conjunction with option cannot be used in conjunction
with <ahref="struct.Cors.html#method.send_wildcard"title="method actix_cors::Cors::send_wildcard">wildcard origins</a> configured. Doing so will result in an error
B: MessageBody + 'static,</div></h3></section></summary><divclass="impl-items"><detailsclass="toggle"open><summary><sectionid="associatedtype.Response"class="associatedtype trait-impl"><ahref="#associatedtype.Response"class="anchor">§</a><h4class="code-header">type <aclass="associatedtype">Response</a> = ServiceResponse<EitherBody<B>></h4></section></summary><divclass='docblock'>Responses produced by the service.</div></details><detailsclass="toggle"open><summary><sectionid="associatedtype.Error"class="associatedtype trait-impl"><ahref="#associatedtype.Error"class="anchor">§</a><h4class="code-header">type <aclass="associatedtype">Error</a> = Error</h4></section></summary><divclass='docblock'>Errors produced by the service.</div></details><detailsclass="toggle"open><summary><sectionid="associatedtype.InitError"class="associatedtype trait-impl"><ahref="#associatedtype.InitError"class="anchor">§</a><h4class="code-header">type <aclass="associatedtype">InitError</a> = <aclass="primitive"href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a></h4></section></summary><divclass='docblock'>Errors produced while building a transform service.</div></details><detailsclass="toggle"open><summary><sectionid="associatedtype.Transform"class="associatedtype trait-impl"><ahref="#associatedtype.Transform"class="anchor">§</a><h4class="code-header">type <aclass="associatedtype">Transform</a> = CorsMiddleware<S></h4></section></summary><divclass='docblock'>The <code>TransformService</code> value created by this factory</div></details><detailsclass="toggle"open><summary><sectionid="associatedtype.Future"class="associatedtype trait-impl"><ahref="#associatedtype.Future"class="anchor">§</a><h4class="code-header">type <aclass="associatedtype">Future</a> = Ready<<aclass="enum"href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html"title="enum core::result::Result">Result</a><<<aclass="struct"href="struct.Cors.html"title="struct actix_cors::Cors">Cors</a> as Transform<S, ServiceRequest>>::Transform, <<aclass="struct"href="struct.Cors.html"title="struct actix_cors::Cors">Cors</a> as Transform<S, ServiceRequest>>::InitError>></h4></section></summary><divclass='docblock'>The future response value.</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.new_transform"class="method trait-impl"><aclass="src rightside"href="../src/actix_cors/builder.rs.html#539-584">source</a><ahref="#method.new_transform"class="anchor">§</a><h4class="code-header">fn <aclass="fn">new_transform</a>(&self, service: S) -> Self::Future</h4></section></summary><divclass='docblock'>Creates and returns a new Transform component, asynchronously</div></details></div></details></div><h2id="synthetic-implementations"class="section-header">Auto Trait Implementations<ahref="#synthetic-implementations"class="anchor">§</a></h2><divid="synthetic-implementations-list"><sectionid="impl-Freeze-for-Cors"class="impl"><ahref="#impl-Freeze-for-Cors"class="anchor">§</a><h3class="code-header">impl <aclass="trait"href="https://doc.rust-lang.org/nightly/core/marker/trait.Freeze.html"title="trait core::marker::Freeze">Freeze</a> for <aclass="struct"href="struct.Cors.html"title="struct actix_cors::Cors">Cors</a></h3></section><sectionid="impl-RefUnwindSafe-for-Cors"class="impl"><ahref="#impl-RefUnwindSafe-for-Cors"class="anchor">§</a><h3class="code-header">impl !<aclass="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 <aclass="struct"href="struct.Cors.html"title="struct actix_cors::Cors">Cors</a></h3></section><sectionid="impl-Send-for-Cors"class="impl"><ahref="#impl-Send-for-Cors"class="anchor">§</a><h3class="code-header">impl !<aclass="trait"href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html"title="trait core::marker::Send">Send</a>
</div></details></div></details><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-Instrument-for-T"class="impl"><ahref="#impl-Instrument-for-T"class="anchor">§</a><h3class="code-header">impl<T> Instrument for T</h3></section></summary><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.instrument"class="method trait-impl"><ahref="#method.instrument"class="anchor">§</a><h4class="code-header">fn <aclass="fn">instrument</a>(self, span: Span) -> Instrumented<Self></h4></section></summary><divclass='docblock'>Instruments this type with the provided [<code>Span</code>], returning an
<code>Instrumented</code> wrapper. <a>Read more</a></div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.in_current_span"class="method trait-impl"><ahref="#method.in_current_span"class="anchor">§</a><h4class="code-header">fn <aclass="fn">in_current_span</a>(self) -> Instrumented<Self></h4></section></summary><divclass='docblock'>Instruments this type with the <ahref="super::Span::current()">current</a><ahref="crate::Span"><code>Span</code></a>, returning an
<code><ahref="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>
U: <aclass="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><divclass="impl-items"><detailsclass="toggle"open><summary><sectionid="associatedtype.Error-1"class="associatedtype trait-impl"><ahref="#associatedtype.Error-1"class="anchor">§</a><h4class="code-header">type <ahref="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error"class="associatedtype">Error</a> = <aclass="enum"href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html"title="enum core::convert::Infallible">Infallible</a></h4></section></summary><divclass='docblock'>The type returned in the event of a conversion error.</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.try_from"class="method trait-impl"><aclass="src rightside"href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#812">source</a><ahref="#method.try_from"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from"class="fn">try_from</a>(value: U) -><aclass="enum"href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html"title="enum core::result::Result">Result</a><T, <T as <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><U>>::<aclass="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><divclass='docblock'>Performs the conversion.</div></details></div></details><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-TryInto%3CU%3E-for-T"class="impl"><aclass="src rightside"href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#790-792">source</a><ahref="#impl-TryInto%3CU%3E-for-T"class="anchor">§</a><h3class="code-header">impl<T, U><aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html"title="trait core::convert::TryInto">TryInto</a><U> for T<divclass="where">where
U: <aclass="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><divclass="impl-items"><detailsclass="toggle"open><summary><sectionid="associatedtype.Error-2"class="associatedtype trait-impl"><ahref="#associatedtype.Error-2"class="anchor">§</a><h4class="code-header">type <ahref="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error"class="associatedtype">Error</a> = <U as <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><T>>::<aclass="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><divclass='docblock'>The type returned in the event of a conversion error.</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.try_into"class="method trait-impl"><aclass="src rightside"href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#797">source</a><ahref="#method.try_into"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into"class="fn">try_into</a>(self) -><aclass="enum"href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html"title="enum core::result::Result">Result</a><U, <U as <aclass="trait"href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><T>>::<aclass="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><divclass='docblock'>Performs the conversion.</div></details></div></details><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-VZip%3CV%3E-for-T"class="impl"><ahref="#impl-VZip%3CV%3E-for-T"class="anchor">§</a><h3class="code-header">impl<V, T> VZip<V> for T<divclass="where">where
S: <aclass="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><divclass='docblock'>Attaches the provided <ahref="super::Subscriber"><code>Subscriber</code></a> to this type, returning a
[<code>WithDispatch</code>] wrapper. <a>Read more</a></div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.with_current_subscriber"class="method trait-impl"><ahref="#method.with_current_subscriber"class="anchor">§</a><h4class="code-header">fn <aclass="fn">with_current_subscriber</a>(self) -> WithDispatch<Self></h4></section></summary><divclass='docblock'>Attaches the current <ahref="crate::dispatcher#setting-the-default-subscriber">default</a><ahref="super::Subscriber"><code>Subscriber</code></a> to this type, returning a