21 lines
5.9 KiB
HTML
21 lines
5.9 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="API documentation for the Rust `call_service` fn in crate `actix_testing`."><meta name="keywords" content="rust, rustlang, rust-lang, call_service"><title>actix_testing::call_service - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../dark.css"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="shortcut icon" href="../favicon.ico"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc fn"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../actix_testing/index.html'><div class='logo-container'><img src='../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><p class='location'><a href='index.html'>actix_testing</a></p><script>window.sidebarCurrent = {name: 'call_service', ty: 'fn', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>−</span>]</a></span><a class='srclink' href='../src/actix_testing/rt.rs.html#110-116' title='goto source code'>[src]</a></span><span class='in-band'>Function <a href='index.html'>actix_testing</a>::<wbr><a class="fn" href=''>call_service</a></span></h1><pre class='rust fn'>pub fn call_service<S, R>(app: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>S, req: R) -> S::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Response" title="type actix_service::Service::Response">Response</a> <span class="where fmt-newline">where<br> S: <a class="trait" href="../actix_service/trait.Service.html" title="trait actix_service::Service">Service</a><Request = R>,<br> S::<a class="type" href="../actix_service/trait.Service.html#associatedtype.Error" title="type actix_service::Service::Error">Error</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>, </span></pre><div class='docblock'><p>Calls service and waits for response future completion.</p>
|
||
|
||
<div class='information'><div class='tooltip ignore'>ⓘ<span class='tooltiptext'>This example is not tested</span></div></div><div class="example-wrap"><pre class="rust rust-example-rendered ignore">
|
||
<span class="kw">use</span> <span class="ident">actix_web</span>::{<span class="ident">test</span>, <span class="ident">App</span>, <span class="ident">HttpResponse</span>, <span class="ident">http</span>::<span class="ident">StatusCode</span>};
|
||
<span class="kw">use</span> <span class="ident">actix_service</span>::<span class="ident">Service</span>;
|
||
|
||
<span class="attribute">#[<span class="ident">test</span>]</span>
|
||
<span class="kw">fn</span> <span class="ident">test_response</span>() {
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">app</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">init_service</span>(
|
||
<span class="ident">App</span>::<span class="ident">new</span>()
|
||
.<span class="ident">service</span>(<span class="ident">web</span>::<span class="ident">resource</span>(<span class="string">"/test"</span>).<span class="ident">to</span>(<span class="op">|</span><span class="op">|</span> <span class="ident">HttpResponse</span>::<span class="prelude-val">Ok</span>()))
|
||
);
|
||
|
||
<span class="comment">// Create request object</span>
|
||
<span class="kw">let</span> <span class="ident">req</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">TestRequest</span>::<span class="ident">with_uri</span>(<span class="string">"/test"</span>).<span class="ident">to_request</span>();
|
||
|
||
<span class="comment">// Call application</span>
|
||
<span class="kw">let</span> <span class="ident">resp</span> <span class="op">=</span> <span class="ident">test</span>::<span class="ident">call_service</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">app</span>, <span class="ident">req</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">resp</span>.<span class="ident">status</span>(), <span class="ident">StatusCode</span>::<span class="ident">OK</span>);
|
||
}</pre></div>
|
||
</div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../";window.currentCrate = "actix_testing";</script><script src="../aliases.js"></script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html> |