1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-24 00:21:08 +01:00
actix-web/actix_web/index.html

77 lines
20 KiB
HTML
Raw Permalink Normal View History

<!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="Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust."><title>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="../crates.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 crate"><!--[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><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section><ul class="block"><li><a href="#reexports">Re-exports</a></li><li><a href="#modules">Modules</a></li><li><a href="#macros">Macros</a></li><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#traits">Traits</a></li><li><a href="#types">Type Aliases</a></li><li><a href="#attributes">Attribute Macros</a></li></ul></section></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>Crate <a class="mod" href="#">actix_web</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/lib.rs.html#1-149">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>actix_web::{get, web, App, HttpServer, Responder};
<span class="attr">#[get(<span class="string">"/hello/{name}"</span>)]
</span><span class="kw">async fn </span>greet(name: web::Path&lt;String&gt;) -&gt; <span class="kw">impl </span>Responder {
<span class="macro">format!</span>(<span class="string">"Hello {}!"</span>, name)
}
<span class="attr">#[actix_web::main] </span><span class="comment">// or #[tokio::main]
</span><span class="kw">async fn </span>main() -&gt; std::io::Result&lt;()&gt; {
HttpServer::new(|| {
App::new().service(greet)
})
.bind((<span class="string">"127.0.0.1"</span>, <span class="number">8080</span>))<span class="question-mark">?
</span>.run()
.<span class="kw">await
</span>}</code></pre></div>
<h2 id="documentation--community-resources"><a class="doc-anchor" href="#documentation--community-resources">§</a>Documentation &amp; Community Resources</h2>
<p>In addition to this API documentation, several other resources are available:</p>
<ul>
<li><a href="https://actix.rs/">Website &amp; User Guide</a></li>
<li><a href="https://github.com/actix/examples">Examples Repository</a></li>
<li><a href="https://discord.gg/NWpN5mmg3x">Community Chat on Discord</a></li>
</ul>
<p>To get started navigating the API docs, you may consider looking at the following pages first:</p>
<ul>
<li>
<p><a href="struct.App.html" title="struct actix_web::App"><code>App</code></a>: This struct represents an Actix Web application and is used to
configure routes and other common application settings.</p>
</li>
<li>
<p><a href="struct.HttpServer.html" title="struct actix_web::HttpServer"><code>HttpServer</code></a>: This struct represents an HTTP server instance and is
used to instantiate and configure servers.</p>
</li>
<li>
<p><a href="web/index.html" title="mod actix_web::web"><code>web</code></a>: This module provides essential types for route registration as well as
common utilities for request handlers.</p>
</li>
<li>
<p><a href="struct.HttpRequest.html" title="struct actix_web::HttpRequest"><code>HttpRequest</code></a> and <a href="struct.HttpResponse.html" title="struct actix_web::HttpResponse"><code>HttpResponse</code></a>: These
structs represent HTTP requests and responses and expose methods for creating, inspecting,
and otherwise utilizing them.</p>
</li>
</ul>
<h2 id="features"><a class="doc-anchor" href="#features">§</a>Features</h2>
<ul>
<li>Supports HTTP/1.x and HTTP/2</li>
<li>Streaming and pipelining</li>
<li>Powerful <a href="https://actix.rs/docs/url-dispatch/">request routing</a> with optional macros</li>
<li>Full <a href="https://tokio.rs">Tokio</a> compatibility</li>
<li>Keep-alive and slow requests handling</li>
<li>Client/server <a href="https://actix.rs/docs/websockets/">WebSockets</a> support</li>
<li>Transparent content compression/decompression (br, gzip, deflate, zstd)</li>
<li>Multipart streams</li>
<li>Static assets</li>
<li>SSL support using OpenSSL or Rustls</li>
<li>Middlewares (<a href="middleware/index.html" title="mod actix_web::middleware">Logger, Session, CORS, etc</a>)</li>
<li>Integrates with the <a href="https://docs.rs/awc/"><code>awc</code> HTTP client</a></li>
<li>Runs on stable Rust 1.54+</li>
</ul>
<h2 id="crate-features"><a class="doc-anchor" href="#crate-features">§</a>Crate Features</h2>
<ul>
<li><code>cookies</code> - cookies support (enabled by default)</li>
<li><code>macros</code> - routing and runtime macros (enabled by default)</li>
<li><code>compress-brotli</code> - brotli content encoding compression support (enabled by default)</li>
<li><code>compress-gzip</code> - gzip and deflate content encoding compression support (enabled by default)</li>
<li><code>compress-zstd</code> - zstd content encoding compression support (enabled by default)</li>
<li><code>openssl</code> - HTTPS support via <code>openssl</code> crate, supports <code>HTTP/2</code></li>
<li><code>rustls</code> - HTTPS support via <code>rustls</code> 0.20 crate, supports <code>HTTP/2</code></li>
<li><code>rustls-0_21</code> - HTTPS support via <code>rustls</code> 0.21 crate, supports <code>HTTP/2</code></li>
<li><code>rustls-0_22</code> - HTTPS support via <code>rustls</code> 0.22 crate, supports <code>HTTP/2</code></li>
<li><code>rustls-0_23</code> - HTTPS support via <code>rustls</code> 0.23 crate, supports <code>HTTP/2</code></li>
<li><code>secure-cookies</code> - secure cookies support</li>
</ul>
</div></details><h2 id="reexports" class="section-header">Re-exports<a href="#reexports" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name" id="reexport.Error"><code>pub use crate::error::<a class="struct" href="error/struct.Error.html" title="struct actix_web::error::Error">Error</a>;</code></div></li><li><div class="item-name" id="reexport.ResponseError"><code>pub use crate::error::<a class="trait" href="error/trait.ResponseError.html" title="trait actix_web::error::ResponseError">ResponseError</a>;</code></div></li></ul><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="body/index.html" title="mod actix_web::body">body</a></div><div class="desc docblock-short">Traits and structures to aid consuming and writing HTTP payloads.</div></li><li><div class="item-name"><a class="mod" href="cookie/index.html" title="mod actix_web::cookie">cookie</a><span class="stab portability" title="Available on crate feature `cookies` only"><code>cookies</code></span></div><div class="desc docblock-short">HTTP cookie parsing and cookie jar management.</div></li><li><div class="item-name"><a class="mod" href="dev/index.html" title="mod actix_web::dev">dev</a></div><div class="desc docblock-short">Lower-level types and re-exports.</div></li><li><div class="item-name"><a class="mod" href="error/index.html" title="mod actix_web::error">error</a></div><div class="desc docblock-short">Error and Result module</div></li><li><div class="item-name"><a class="mod" href="guard/index.html" title="mod actix_web::guard">guard</a></div><div class="desc docblock-short">Route guards.</div></li><li><div class="item-name"><a class="mod" href="http/index.html" title="mod actix_web::http">http</a></div><div class="desc docblock-short">Various HTTP related types.</div></li><li><div class="item-name"><a class="mod" href="middleware/index.html" title="mod actix_web::middleware">middleware</a></div><div class="desc docblock-short">A collection of common middleware.</div></li><li><div class="item-name"><a class="mod" href="rt/index.html" title="mod actix_web::rt">rt</a></div><div class="desc docblock-short">A selection of re-exports from <a href="https://docs.rs/tokio"><code>tokio</code></a> and <a href="https://docs.rs/actix-rt"><code>actix-rt</code></a>.</div></li><li><div class="item-name"><a class="mod" href="test/index.html" title="mod actix_web::test">test</a></div><div class="desc docblock-short">Various helpers for Actix applications to use during testing.</div></li><li><div class="item-name"><a class="mod" href="web/index.html" title="mod actix_web::web">web</a></div><div class="desc docblock-short">Essentials helper functions and types for application registration.</div></li></ul><h2 id="macros" class="section-header">Macros<a href="#macros" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="macro" href="macro.services.html" title="macro actix_web::services">services</a></div><div class="desc docblock-short">Macro to help register different types of services at the same time.</div></li></ul><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.App.html" title="struct actix_web::App">App</a></div><div class="desc docblock-short">The top-level builder for an Actix Web application.</div></li><li><div class="item-name"><a class="struct" href="struct.CustomizeResponder.html" title="struct actix_web::CustomizeResponder">CustomizeResponder</a></div><div class="desc docblock-short">Allows overriding status code and headers for a <a href="trait.Responder.html" title="trait actix_web::Responder"><code>Responder</code></a>.</div></li><li><div class="item-name"><a class="struct" href="struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a></div><div class="desc docblock-short">An incoming request.</div></li><li><div class="item-name"><a class="struct" href="s
the request. Some types that implement this trait are: <a href="web/struct.Json.html" title="struct actix_web::web::Json"><code>Json</code></a>, <a href="web/struct.Header.html" title="struct actix_web::web::Header"><code>Header</code></a>, and <a href="web/struct.Path.html" title="struct actix_web::web::Path"><code>Path</code></a>.</div></li><li><div class="item-name"><a class="trait" href="trait.Handler.html" title="trait actix_web::Handler">Handler</a></div><div class="desc docblock-short">The interface for request handlers.</div></li><li><div class="item-name"><a class="trait" href="trait.HttpMessage.html" title="trait actix_web::HttpMessage">HttpMessage</a></div><div class="desc docblock-short">Trait that implements general purpose operations on HTTP messages.</div></li><li><div class="item-name"><a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a></div><div class="desc docblock-short">Trait implemented by types that can be converted to an HTTP response.</div></li></ul><h2 id="types" class="section-header">Type Aliases<a href="#types" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="type" href="type.Result.html" title="type actix_web::Result">Result</a></div><div class="desc docblock-short">A convenience <a href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result"><code>Result</code></a> for Actix Web operations.</div></li></ul><h2 id="attributes" class="section-header">Attribute Macros<a href="#attributes" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="attr" href="attr.connect.html" title="attr actix_web::connect">connect</a><span class="stab portability" title="Available on crate feature `macros` only"><code>macros</code></span></div><div class="desc docblock-short">Creates route handler with <code>actix_web::guard::Connect</code>.</div></li><li><div class="item-name"><a class="attr" href="attr.delete.html" title="attr actix_web::delete">delete</a><span class="stab portability" title="Available on crate feature `macros` only"><code>macros</code></span></div><div class="desc docblock-short">Creates route handler with <code>actix_web::guard::Delete</code>.</div></li><li><div class="item-name"><a class="attr" href="attr.get.html" title="attr actix_web::get">get</a><span class="stab portability" title="Available on crate feature `macros` only"><code>macros</code></span></div><div class="desc docblock-short">Creates route handler with <code>actix_web::guard::Get</code>.</div></li><li><div class="item-name"><a class="attr" href="attr.head.html" title="attr actix_web::head">head</a><span class="stab portability" title="Available on crate feature `macros` only"><code>macros</code></span></div><div class="desc docblock-short">Creates route handler with <code>actix_web::guard::Head</code>.</div></li><li><div class="item-name"><a class="attr" href="attr.main.html" title="attr actix_web::main">main</a><span class="stab portability" title="Available on crate feature `macros` only"><code>macros</code></span></div><div class="desc docblock-short">Marks async main function as the Actix Web system entry-point.</div></li><li><div class="item-name"><a class="attr" href="attr.options.html" title="attr actix_web::options">options</a><span class="stab portability" title="Available on crate feature `macros` only"><code>macros</code></span></div><div class="desc docblock-short">Creates route handler with <code>actix_web::guard::Options</code>.</div></li><li><div class="item-name"><a class="attr" href="attr.patch.html" title="attr actix_web::patch">patch</a><span class="stab portability" title="Available on crate feature `macros` only"><code>macros</code></span></div><div class="desc docblock-short">Creates route handler with <code>actix_web::guard::Patch</code>.</div></li><li><div class="item-name"><a class="attr" href="attr.post.html" title="attr actix_web::post">post</a><span class="stab portability" title="Available on crate feature `macros` only"><code>macros</code></span>