mirror of
https://github.com/actix/actix-web.git
synced 2024-11-22 09:31:10 +00:00
don't use rust annotation on code doc blocks
This commit is contained in:
parent
9704beddf8
commit
3188ef5731
36 changed files with 99 additions and 99 deletions
|
@ -19,7 +19,7 @@ use crate::{
|
|||
///
|
||||
/// `Files` service must be registered with `App::service()` method.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::App;
|
||||
/// use actix_files::Files;
|
||||
///
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//! Provides a non-blocking service for serving static files from disk.
|
||||
//!
|
||||
//! # Example
|
||||
//! ```rust
|
||||
//! ```
|
||||
//! use actix_web::App;
|
||||
//! use actix_files::Files;
|
||||
//!
|
||||
|
|
|
@ -60,7 +60,7 @@ impl NamedFile {
|
|||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_files::NamedFile;
|
||||
/// use std::io::{self, Write};
|
||||
/// use std::env;
|
||||
|
@ -137,7 +137,7 @@ impl NamedFile {
|
|||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_files::NamedFile;
|
||||
///
|
||||
/// let file = NamedFile::open("foo.txt");
|
||||
|
@ -156,7 +156,7 @@ impl NamedFile {
|
|||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use std::io;
|
||||
/// use actix_files::NamedFile;
|
||||
///
|
||||
|
|
|
@ -26,7 +26,7 @@ use socket2::{Domain, Protocol, Socket, Type};
|
|||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_http::HttpService;
|
||||
/// use actix_http_test::TestServer;
|
||||
/// use actix_web::{web, App, HttpResponse, Error};
|
||||
|
|
|
@ -47,7 +47,7 @@ enum SslConnector {
|
|||
/// The `Connector` type uses a builder-like combinator pattern for service
|
||||
/// construction that finishes by calling the `.finish()` method.
|
||||
///
|
||||
/// ```rust,ignore
|
||||
/// ```ignore
|
||||
/// use std::time::Duration;
|
||||
/// use actix_http::client::Connector;
|
||||
///
|
||||
|
|
|
@ -483,7 +483,7 @@ where
|
|||
/// response as opposite to *INTERNAL SERVER ERROR* which is defined by
|
||||
/// default.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use std::io;
|
||||
/// # use actix_http::*;
|
||||
///
|
||||
|
|
|
@ -36,7 +36,7 @@ use crate::header::{
|
|||
/// builder.insert_header(CacheControl(vec![CacheDirective::MaxAge(86400u32)]));
|
||||
/// ```
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_http::Response;
|
||||
/// use actix_http::http::header::{CacheControl, CacheDirective};
|
||||
///
|
||||
|
|
|
@ -357,7 +357,7 @@ impl ResponseBuilder {
|
|||
|
||||
/// Insert a header, replacing any that were set with an equivalent field name.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use actix_http::Response;
|
||||
/// use actix_http::http::header::ContentType;
|
||||
///
|
||||
|
@ -384,7 +384,7 @@ impl ResponseBuilder {
|
|||
|
||||
/// Append a header, keeping any that were set with an equivalent field name.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use actix_http::Response;
|
||||
/// use actix_http::http::header::ContentType;
|
||||
///
|
||||
|
@ -525,7 +525,7 @@ impl ResponseBuilder {
|
|||
|
||||
/// Set a cookie
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_http::{http, Request, Response};
|
||||
///
|
||||
/// fn index(req: Request) -> Response {
|
||||
|
@ -555,7 +555,7 @@ impl ResponseBuilder {
|
|||
|
||||
/// Remove cookie
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_http::{http, Request, Response, HttpMessage};
|
||||
///
|
||||
/// fn index(req: Request) -> Response {
|
||||
|
|
|
@ -26,7 +26,7 @@ use crate::{
|
|||
|
||||
/// Test `Request` builder
|
||||
///
|
||||
/// ```rust,ignore
|
||||
/// ```ignore
|
||||
/// # use http::{header, StatusCode};
|
||||
/// # use actix_web::*;
|
||||
/// use actix_web::test::TestRequest;
|
||||
|
|
|
@ -10,7 +10,7 @@ use crate::server::Multipart;
|
|||
///
|
||||
/// ## Server example
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use futures_util::stream::{Stream, StreamExt};
|
||||
/// use actix_web::{web, HttpResponse, Error};
|
||||
/// use actix_multipart as mp;
|
||||
|
|
|
@ -82,7 +82,7 @@ mod route;
|
|||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use actix_web::HttpResponse;
|
||||
/// # use actix_web_codegen::route;
|
||||
/// #[route("/test", method="GET", method="HEAD")]
|
||||
|
@ -127,7 +127,7 @@ code, e.g `my_guard` or `my_module::my_guard`.
|
|||
|
||||
# Example
|
||||
|
||||
```rust
|
||||
```
|
||||
# use actix_web::HttpResponse;
|
||||
# use actix_web_codegen::"#, stringify!($method), ";
|
||||
#[", stringify!($method), r#"("/")]
|
||||
|
@ -162,7 +162,7 @@ method_macro! {
|
|||
/// This macro can be applied with `#[actix_web::main]` when used in Actix Web applications.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// #[actix_web_codegen::main]
|
||||
/// async fn main() {
|
||||
/// async { println!("Hello world"); }.await
|
||||
|
|
|
@ -131,7 +131,7 @@ pub use self::sender::SendClientRequest;
|
|||
///
|
||||
/// ## Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use awc::Client;
|
||||
///
|
||||
/// #[actix_rt::main]
|
||||
|
|
|
@ -36,7 +36,7 @@ cfg_if::cfg_if! {
|
|||
/// This type can be used to construct an instance of `ClientRequest` through a
|
||||
/// builder-like pattern.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// #[actix_rt::main]
|
||||
/// async fn main() {
|
||||
/// let response = awc::Client::new()
|
||||
|
@ -190,7 +190,7 @@ impl ClientRequest {
|
|||
|
||||
/// Append a header, keeping any that were set with an equivalent field name.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # #[actix_rt::main]
|
||||
/// # async fn main() {
|
||||
/// # use awc::Client;
|
||||
|
@ -271,7 +271,7 @@ impl ClientRequest {
|
|||
|
||||
/// Set a cookie
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// #[actix_rt::main]
|
||||
/// async fn main() {
|
||||
/// let resp = awc::Client::new().get("https://www.rust-lang.org")
|
||||
|
|
|
@ -9,7 +9,7 @@ use actix_web::test::{init_service, ok_service, TestRequest};
|
|||
|
||||
/// Criterion Benchmark for async Service
|
||||
/// Should be used from within criterion group:
|
||||
/// ```rust,ignore
|
||||
/// ```ignore
|
||||
/// let mut criterion: ::criterion::Criterion<_> =
|
||||
/// ::criterion::Criterion::default().configure_from_args();
|
||||
/// bench_async_service(&mut criterion, ok_service(), "async_service_direct");
|
||||
|
|
16
src/app.rs
16
src/app.rs
|
@ -79,7 +79,7 @@ where
|
|||
/// uses `Arc` so data could be created outside of app factory and clones could
|
||||
/// be stored via `App::app_data()` method.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use std::cell::Cell;
|
||||
/// use actix_web::{web, App, HttpResponse, Responder};
|
||||
///
|
||||
|
@ -152,7 +152,7 @@ where
|
|||
/// different module or even library. For example,
|
||||
/// some of the resource's configuration could be moved to different module.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, App, HttpResponse};
|
||||
///
|
||||
/// // this function could be located in different module
|
||||
|
@ -185,7 +185,7 @@ where
|
|||
/// This method can be used multiple times with same path, in that case
|
||||
/// multiple resources with one route would be registered for same resource path.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, App, HttpResponse};
|
||||
///
|
||||
/// async fn index(data: web::Path<(String, String)>) -> &'static str {
|
||||
|
@ -228,7 +228,7 @@ where
|
|||
///
|
||||
/// It is possible to use services like `Resource`, `Route`.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, App, HttpResponse};
|
||||
///
|
||||
/// async fn index() -> &'static str {
|
||||
|
@ -246,7 +246,7 @@ where
|
|||
///
|
||||
/// It is also possible to use static files as default service.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, App, HttpResponse};
|
||||
///
|
||||
/// fn main() {
|
||||
|
@ -283,7 +283,7 @@ where
|
|||
/// and are never considered for matching at request time. Calls to
|
||||
/// `HttpRequest::url_for()` will work as expected.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, App, HttpRequest, HttpResponse, Result};
|
||||
///
|
||||
/// async fn index(req: HttpRequest) -> Result<HttpResponse> {
|
||||
|
@ -325,7 +325,7 @@ where
|
|||
/// the builder chain. Consequently, the *first* middleware registered
|
||||
/// in the builder chain is the *last* to execute during request processing.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_service::Service;
|
||||
/// use actix_web::{middleware, web, App};
|
||||
/// use actix_web::http::{header::CONTENT_TYPE, HeaderValue};
|
||||
|
@ -382,7 +382,7 @@ where
|
|||
///
|
||||
/// Use middleware when you need to read or modify *every* request or response in some way.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_service::Service;
|
||||
/// use actix_web::{web, App};
|
||||
/// use actix_web::http::{header::CONTENT_TYPE, HeaderValue};
|
||||
|
|
|
@ -37,7 +37,7 @@ pub(crate) type FnDataFactory =
|
|||
/// If route data is not set for a handler, using `Data<T>` extractor would cause *Internal
|
||||
/// Server Error* response.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use std::sync::Mutex;
|
||||
/// use actix_web::{web, App, HttpResponse, Responder};
|
||||
///
|
||||
|
|
|
@ -51,7 +51,7 @@ pub trait FromRequest: Sized {
|
|||
///
|
||||
/// ## Example
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, dev, App, Error, HttpRequest, FromRequest};
|
||||
/// use actix_web::error::ErrorBadRequest;
|
||||
/// use futures_util::future::{ok, err, Ready};
|
||||
|
@ -143,7 +143,7 @@ where
|
|||
///
|
||||
/// ## Example
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, dev, App, Result, Error, HttpRequest, FromRequest};
|
||||
/// use actix_web::error::ErrorBadRequest;
|
||||
/// use futures_util::future::{ok, err, Ready};
|
||||
|
|
10
src/guard.rs
10
src/guard.rs
|
@ -12,7 +12,7 @@
|
|||
//! to store extra attributes on a request by using the `Extensions` container.
|
||||
//! Extensions containers are available via the `RequestHead::extensions()` method.
|
||||
//!
|
||||
//! ```rust
|
||||
//! ```
|
||||
//! use actix_web::{web, http, dev, guard, App, HttpResponse};
|
||||
//!
|
||||
//! fn main() {
|
||||
|
@ -42,7 +42,7 @@ pub trait Guard {
|
|||
|
||||
/// Create guard object for supplied function.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{guard, web, App, HttpResponse};
|
||||
///
|
||||
/// fn main() {
|
||||
|
@ -85,7 +85,7 @@ where
|
|||
|
||||
/// Return guard that matches if any of supplied guards.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, guard, App, HttpResponse};
|
||||
///
|
||||
/// fn main() {
|
||||
|
@ -124,7 +124,7 @@ impl Guard for AnyGuard {
|
|||
|
||||
/// Return guard that matches if all of the supplied guards.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{guard, web, App, HttpResponse};
|
||||
///
|
||||
/// fn main() {
|
||||
|
@ -259,7 +259,7 @@ impl Guard for HeaderGuard {
|
|||
|
||||
/// Return predicate that matches if request contains specified Host name.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, guard::Host, App, HttpResponse};
|
||||
///
|
||||
/// fn main() {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//!
|
||||
//! ## Example
|
||||
//!
|
||||
//! ```rust,no_run
|
||||
//! ```no_run
|
||||
//! use actix_web::{get, web, App, HttpServer, Responder};
|
||||
//!
|
||||
//! #[get("/{id}/{name}/index.html")]
|
||||
|
|
|
@ -16,7 +16,7 @@ use crate::{error::Error, service::ServiceResponse};
|
|||
/// [`Scope::wrap`](crate::Scope::wrap) and [`Condition`](super::Condition).
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::middleware::{Logger, Compat};
|
||||
/// use actix_web::{App, web};
|
||||
///
|
||||
|
|
|
@ -31,7 +31,7 @@ use crate::{
|
|||
/// encoding to `ContentEncoding::Identity`.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, middleware, App, HttpResponse};
|
||||
///
|
||||
/// let app = App::new()
|
||||
|
|
|
@ -12,7 +12,7 @@ use futures_util::future::{Either, FutureExt, LocalBoxFuture};
|
|||
/// middleware for a workaround.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::middleware::{Condition, NormalizePath};
|
||||
/// use actix_web::App;
|
||||
///
|
||||
|
|
|
@ -29,7 +29,7 @@ use crate::{
|
|||
/// Headers with the same key that are already set in a response will *not* be overwritten.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, http, middleware, App, HttpResponse};
|
||||
///
|
||||
/// fn main() {
|
||||
|
|
|
@ -34,7 +34,7 @@ type ErrorHandler<B> = dyn Fn(ServiceResponse<B>) -> Result<ErrorHandlerResponse
|
|||
/// for a given status code. Handlers can modify existing responses or create completely new ones.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::middleware::{ErrorHandlers, ErrorHandlerResponse};
|
||||
/// use actix_web::{web, http, dev, App, HttpRequest, HttpResponse, Result};
|
||||
///
|
||||
|
|
|
@ -43,7 +43,7 @@ use crate::{
|
|||
/// ```
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{middleware::Logger, App};
|
||||
///
|
||||
/// // access logs are printed with the INFO level so ensure it is enabled by default
|
||||
|
@ -124,7 +124,7 @@ impl Logger {
|
|||
/// It is convention to print "-" to indicate no output instead of an empty string.
|
||||
///
|
||||
/// # Example
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use actix_web::{http::HeaderValue, middleware::Logger};
|
||||
/// # fn parse_jwt_id (_req: Option<&HeaderValue>) -> String { "jwt_uid".to_owned() }
|
||||
/// Logger::new("example %{JWT_ID}xi")
|
||||
|
|
|
@ -54,7 +54,7 @@ impl Default for TrailingSlash {
|
|||
/// `TrailingSlash::Always` behavior), as shown in the example tests below.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, middleware, App};
|
||||
///
|
||||
/// # actix_web::rt::System::new().block_on(async {
|
||||
|
|
|
@ -159,7 +159,7 @@ impl HttpRequest {
|
|||
|
||||
/// Generate url for named resource
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use actix_web::{web, App, HttpRequest, HttpResponse};
|
||||
/// #
|
||||
/// fn index(req: HttpRequest) -> HttpResponse {
|
||||
|
@ -231,7 +231,7 @@ impl HttpRequest {
|
|||
///
|
||||
/// If `App::data` was used to store object, use `Data<T>`:
|
||||
///
|
||||
/// ```rust,ignore
|
||||
/// ```ignore
|
||||
/// let opt_t = req.app_data::<Data<T>>();
|
||||
/// ```
|
||||
pub fn app_data<T: 'static>(&self) -> Option<&T> {
|
||||
|
@ -302,7 +302,7 @@ impl Drop for HttpRequest {
|
|||
///
|
||||
/// ## Example
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, App, HttpRequest};
|
||||
/// use serde_derive::Deserialize;
|
||||
///
|
||||
|
|
|
@ -23,7 +23,7 @@ use crate::{dev::Payload, FromRequest, HttpRequest};
|
|||
/// provided to make this potential foot-gun more obvious.
|
||||
///
|
||||
/// # Example
|
||||
/// ```rust,no_run
|
||||
/// ```no_run
|
||||
/// # use actix_web::{web, HttpResponse, HttpRequest, Responder};
|
||||
///
|
||||
/// #[derive(Debug, Clone, PartialEq)]
|
||||
|
|
|
@ -35,7 +35,7 @@ type HttpNewService = BoxServiceFactory<(), ServiceRequest, ServiceResponse, Err
|
|||
/// and check guards for specific route, if request matches all
|
||||
/// guards, route considered matched and route handler get called.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, App, HttpResponse};
|
||||
///
|
||||
/// fn main() {
|
||||
|
@ -97,7 +97,7 @@ where
|
|||
|
||||
/// Add match guard to a resource.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, guard, App, HttpResponse};
|
||||
///
|
||||
/// async fn index(data: web::Path<(String, String)>) -> &'static str {
|
||||
|
@ -130,7 +130,7 @@ where
|
|||
|
||||
/// Register a new route.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, guard, App, HttpResponse};
|
||||
///
|
||||
/// fn main() {
|
||||
|
@ -147,7 +147,7 @@ where
|
|||
/// Multiple routes could be added to a resource. Resource object uses
|
||||
/// match guards for route selection.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, guard, App};
|
||||
///
|
||||
/// fn main() {
|
||||
|
@ -172,7 +172,7 @@ where
|
|||
/// Provided data is available for all routes registered for the current resource.
|
||||
/// Resource data overrides data registered by `App::data()` method.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, App, FromRequest};
|
||||
///
|
||||
/// /// extract text data from request
|
||||
|
@ -211,7 +211,7 @@ where
|
|||
|
||||
/// Register a new route and add handler. This route matches all requests.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::*;
|
||||
///
|
||||
/// fn index(req: HttpRequest) -> HttpResponse {
|
||||
|
@ -223,7 +223,7 @@ where
|
|||
///
|
||||
/// This is shortcut for:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # extern crate actix_web;
|
||||
/// # use actix_web::*;
|
||||
/// # fn index(req: HttpRequest) -> HttpResponse { unimplemented!() }
|
||||
|
@ -289,7 +289,7 @@ where
|
|||
/// Resource level middlewares are not allowed to change response
|
||||
/// type (i.e modify response's body).
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_service::Service;
|
||||
/// use actix_web::{web, App};
|
||||
/// use actix_web::http::{header::CONTENT_TYPE, HeaderValue};
|
||||
|
|
|
@ -18,7 +18,7 @@ pub trait Responder {
|
|||
|
||||
/// Override a status code for a Responder.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{http::StatusCode, HttpRequest, Responder};
|
||||
///
|
||||
/// fn index(req: HttpRequest) -> impl Responder {
|
||||
|
@ -36,7 +36,7 @@ pub trait Responder {
|
|||
///
|
||||
/// Overrides other headers with the same name.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, HttpRequest, Responder};
|
||||
/// use serde::Serialize;
|
||||
///
|
||||
|
@ -169,7 +169,7 @@ impl<T: Responder> CustomResponder<T> {
|
|||
|
||||
/// Override a status code for the Responder's response.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{HttpRequest, Responder, http::StatusCode};
|
||||
///
|
||||
/// fn index(req: HttpRequest) -> impl Responder {
|
||||
|
@ -185,7 +185,7 @@ impl<T: Responder> CustomResponder<T> {
|
|||
///
|
||||
/// Overrides other headers with the same name.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, HttpRequest, Responder};
|
||||
/// use serde::Serialize;
|
||||
///
|
||||
|
|
|
@ -90,7 +90,7 @@ impl Service<ServiceRequest> for RouteService {
|
|||
impl Route {
|
||||
/// Add method guard to the route.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use actix_web::*;
|
||||
/// # fn main() {
|
||||
/// App::new().service(web::resource("/path").route(
|
||||
|
@ -110,7 +110,7 @@ impl Route {
|
|||
|
||||
/// Add guard to the route.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use actix_web::*;
|
||||
/// # fn main() {
|
||||
/// App::new().service(web::resource("/path").route(
|
||||
|
@ -128,7 +128,7 @@ impl Route {
|
|||
|
||||
/// Set handler function, use request extractors for parameters.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, http, App};
|
||||
/// use serde_derive::Deserialize;
|
||||
///
|
||||
|
@ -152,7 +152,7 @@ impl Route {
|
|||
///
|
||||
/// It is possible to use multiple extractors for one handler function.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use std::collections::HashMap;
|
||||
/// # use serde_derive::Deserialize;
|
||||
/// use actix_web::{web, App};
|
||||
|
|
14
src/scope.rs
14
src/scope.rs
|
@ -40,7 +40,7 @@ type HttpNewService = BoxServiceFactory<(), ServiceRequest, ServiceResponse, Err
|
|||
/// You can get variable path segments from `HttpRequest::match_info()`.
|
||||
/// `Path` extractor also is able to extract scope level variable segments.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, App, HttpResponse};
|
||||
///
|
||||
/// fn main() {
|
||||
|
@ -97,7 +97,7 @@ where
|
|||
{
|
||||
/// Add match guard to a scope.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, guard, App, HttpRequest, HttpResponse};
|
||||
///
|
||||
/// async fn index(data: web::Path<(String, String)>) -> &'static str {
|
||||
|
@ -123,7 +123,7 @@ where
|
|||
/// Set or override application data. Application data could be accessed
|
||||
/// by using `Data<T>` extractor where `T` is data type.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use std::cell::Cell;
|
||||
/// use actix_web::{web, App, HttpResponse, Responder};
|
||||
///
|
||||
|
@ -168,7 +168,7 @@ where
|
|||
/// different module or even library. For example,
|
||||
/// some of the resource's configuration could be moved to different module.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # extern crate actix_web;
|
||||
/// use actix_web::{web, middleware, App, HttpResponse};
|
||||
///
|
||||
|
@ -215,7 +215,7 @@ where
|
|||
/// * *Scope* is a set of resources with common root path.
|
||||
/// * "StaticFiles" is a service for static files support
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, App, HttpRequest};
|
||||
///
|
||||
/// struct AppState;
|
||||
|
@ -247,7 +247,7 @@ where
|
|||
/// This method can be called multiple times, in that case
|
||||
/// multiple resources with one route would be registered for same resource path.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, App, HttpResponse};
|
||||
///
|
||||
/// async fn index(data: web::Path<(String, String)>) -> &'static str {
|
||||
|
@ -341,7 +341,7 @@ where
|
|||
/// to Route or Application level middleware, in that Scope-level middleware
|
||||
/// can not modify ServiceResponse.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_service::Service;
|
||||
/// use actix_web::{web, App};
|
||||
/// use actix_web::http::{header::CONTENT_TYPE, HeaderValue};
|
||||
|
|
|
@ -35,7 +35,7 @@ struct Config {
|
|||
///
|
||||
/// Create new HTTP server with application factory.
|
||||
///
|
||||
/// ```rust,no_run
|
||||
/// ```no_run
|
||||
/// use actix_web::{web, App, HttpResponse, HttpServer};
|
||||
///
|
||||
/// #[actix_rt::main]
|
||||
|
@ -588,7 +588,7 @@ where
|
|||
/// This methods panics if no socket address can be bound or an `Actix` system is not yet
|
||||
/// configured.
|
||||
///
|
||||
/// ```rust,no_run
|
||||
/// ```no_run
|
||||
/// use std::io;
|
||||
/// use actix_web::{web, App, HttpResponse, HttpServer};
|
||||
///
|
||||
|
|
|
@ -462,7 +462,7 @@ impl WebService {
|
|||
|
||||
/// Add match guard to a web service.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, guard, dev, App, Error, HttpResponse};
|
||||
///
|
||||
/// async fn index(req: dev::ServiceRequest) -> Result<dev::ServiceResponse, Error> {
|
||||
|
|
18
src/test.rs
18
src/test.rs
|
@ -54,7 +54,7 @@ pub fn default_service(
|
|||
/// This method accepts application builder instance, and constructs
|
||||
/// service.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_service::Service;
|
||||
/// use actix_web::{test, web, App, HttpResponse, http::StatusCode};
|
||||
///
|
||||
|
@ -101,7 +101,7 @@ where
|
|||
|
||||
/// Calls service and waits for response future completion.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{test, web, App, HttpResponse, http::StatusCode};
|
||||
///
|
||||
/// #[actix_rt::test]
|
||||
|
@ -131,7 +131,7 @@ where
|
|||
|
||||
/// Helper function that returns a response body of a TestRequest
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{test, web, App, HttpResponse, http::header};
|
||||
/// use bytes::Bytes;
|
||||
///
|
||||
|
@ -174,7 +174,7 @@ where
|
|||
|
||||
/// Helper function that returns a response body of a ServiceResponse.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{test, web, App, HttpResponse, http::header};
|
||||
/// use bytes::Bytes;
|
||||
///
|
||||
|
@ -212,7 +212,7 @@ where
|
|||
|
||||
/// Helper function that returns a deserialized response body of a ServiceResponse.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{App, test, web, HttpResponse, http::header};
|
||||
/// use serde::{Serialize, Deserialize};
|
||||
///
|
||||
|
@ -271,7 +271,7 @@ where
|
|||
|
||||
/// Helper function that returns a deserialized response body of a TestRequest
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{App, test, web, HttpResponse, http::header};
|
||||
/// use serde::{Serialize, Deserialize};
|
||||
///
|
||||
|
@ -324,7 +324,7 @@ where
|
|||
/// * `TestRequest::to_srv_response` creates `ServiceResponse` instance.
|
||||
/// * `TestRequest::to_http_request` creates `HttpRequest` instance, which is used for testing handlers.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{test, HttpRequest, HttpResponse, HttpMessage};
|
||||
/// use actix_web::http::{header, StatusCode};
|
||||
///
|
||||
|
@ -572,7 +572,7 @@ impl TestRequest {
|
|||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, test, App, HttpResponse, Error};
|
||||
///
|
||||
/// async fn my_handler() -> Result<HttpResponse, Error> {
|
||||
|
@ -612,7 +612,7 @@ where
|
|||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, test, App, HttpResponse, Error};
|
||||
///
|
||||
/// async fn my_handler() -> Result<HttpResponse, Error> {
|
||||
|
|
24
src/web.rs
24
src/web.rs
|
@ -42,7 +42,7 @@ pub use crate::types::*;
|
|||
/// `/users/{userid}/{friend}` and store `userid` and `friend` in
|
||||
/// the exposed `Params` object:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # extern crate actix_web;
|
||||
/// use actix_web::{web, App, HttpResponse};
|
||||
///
|
||||
|
@ -61,7 +61,7 @@ pub fn resource<T: IntoPattern>(path: T) -> Resource {
|
|||
/// Scopes collect multiple paths under a common path prefix.
|
||||
/// Scope path can contain variable path segments as resources.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, App, HttpResponse};
|
||||
///
|
||||
/// let app = App::new().service(
|
||||
|
@ -88,7 +88,7 @@ pub fn route() -> Route {
|
|||
|
||||
/// Create *route* with `GET` method guard.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, App, HttpResponse};
|
||||
///
|
||||
/// let app = App::new().service(
|
||||
|
@ -106,7 +106,7 @@ pub fn get() -> Route {
|
|||
|
||||
/// Create *route* with `POST` method guard.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, App, HttpResponse};
|
||||
///
|
||||
/// let app = App::new().service(
|
||||
|
@ -124,7 +124,7 @@ pub fn post() -> Route {
|
|||
|
||||
/// Create *route* with `PUT` method guard.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, App, HttpResponse};
|
||||
///
|
||||
/// let app = App::new().service(
|
||||
|
@ -142,7 +142,7 @@ pub fn put() -> Route {
|
|||
|
||||
/// Create *route* with `PATCH` method guard.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, App, HttpResponse};
|
||||
///
|
||||
/// let app = App::new().service(
|
||||
|
@ -160,7 +160,7 @@ pub fn patch() -> Route {
|
|||
|
||||
/// Create *route* with `DELETE` method guard.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, App, HttpResponse};
|
||||
///
|
||||
/// let app = App::new().service(
|
||||
|
@ -178,7 +178,7 @@ pub fn delete() -> Route {
|
|||
|
||||
/// Create *route* with `HEAD` method guard.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, App, HttpResponse};
|
||||
///
|
||||
/// let app = App::new().service(
|
||||
|
@ -196,7 +196,7 @@ pub fn head() -> Route {
|
|||
|
||||
/// Create *route* with `TRACE` method guard.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, App, HttpResponse};
|
||||
///
|
||||
/// let app = App::new().service(
|
||||
|
@ -214,7 +214,7 @@ pub fn trace() -> Route {
|
|||
|
||||
/// Create *route* and add method guard.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, http, App, HttpResponse};
|
||||
///
|
||||
/// let app = App::new().service(
|
||||
|
@ -232,7 +232,7 @@ pub fn method(method: Method) -> Route {
|
|||
|
||||
/// Create a new route and add handler.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{web, App, HttpResponse, Responder};
|
||||
///
|
||||
/// async fn index() -> impl Responder {
|
||||
|
@ -256,7 +256,7 @@ where
|
|||
|
||||
/// Create raw service for a specific path.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use actix_web::{dev, web, guard, App, Error, HttpResponse};
|
||||
///
|
||||
/// async fn my_service(req: dev::ServiceRequest) -> Result<dev::ServiceResponse, Error> {
|
||||
|
|
Loading…
Reference in a new issue