fix doctest refs

This commit is contained in:
Rob Ede 2021-12-05 06:21:57 +00:00
parent d39c2a89b2
commit 040bcb0bf0
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
6 changed files with 15 additions and 17 deletions

View File

@ -20,7 +20,7 @@ use crate::{
/// ///
/// # Examples /// # Examples
/// ``` /// ```
/// use actix_http::{Response, ResponseBuilder, body, http::StatusCode, http::header}; /// use actix_http::{Response, ResponseBuilder, StatusCode, body, header};
/// ///
/// # actix_rt::System::new().block_on(async { /// # actix_rt::System::new().block_on(async {
/// let mut res: Response<_> = Response::build(StatusCode::OK) /// let mut res: Response<_> = Response::build(StatusCode::OK)
@ -47,9 +47,7 @@ impl ResponseBuilder {
/// Create response builder /// Create response builder
/// ///
/// # Examples /// # Examples
/// ``` // /// use actix_http::{Response, ResponseBuilder, StatusCode};, / ``
/// use actix_http::{Response, ResponseBuilder, http::StatusCode};
///
/// let res: Response<_> = ResponseBuilder::default().finish(); /// let res: Response<_> = ResponseBuilder::default().finish();
/// assert_eq!(res.status(), StatusCode::OK); /// assert_eq!(res.status(), StatusCode::OK);
/// ``` /// ```
@ -64,9 +62,7 @@ impl ResponseBuilder {
/// Set HTTP status code of this response. /// Set HTTP status code of this response.
/// ///
/// # Examples /// # Examples
/// ``` // /// use actix_http::{ResponseBuilder, StatusCode};, / ``
/// use actix_http::{ResponseBuilder, http::StatusCode};
///
/// let res = ResponseBuilder::default().status(StatusCode::NOT_FOUND).finish(); /// let res = ResponseBuilder::default().status(StatusCode::NOT_FOUND).finish();
/// assert_eq!(res.status(), StatusCode::NOT_FOUND); /// assert_eq!(res.status(), StatusCode::NOT_FOUND);
/// ``` /// ```
@ -82,7 +78,7 @@ impl ResponseBuilder {
/// ///
/// # Examples /// # Examples
/// ``` /// ```
/// use actix_http::{ResponseBuilder, http::header}; /// use actix_http::{ResponseBuilder, header};
/// ///
/// let res = ResponseBuilder::default() /// let res = ResponseBuilder::default()
/// .insert_header((header::CONTENT_TYPE, mime::APPLICATION_JSON)) /// .insert_header((header::CONTENT_TYPE, mime::APPLICATION_JSON))
@ -112,7 +108,7 @@ impl ResponseBuilder {
/// ///
/// # Examples /// # Examples
/// ``` /// ```
/// use actix_http::{ResponseBuilder, http::header}; /// use actix_http::{ResponseBuilder, header};
/// ///
/// let res = ResponseBuilder::default() /// let res = ResponseBuilder::default()
/// .append_header((header::CONTENT_TYPE, mime::APPLICATION_JSON)) /// .append_header((header::CONTENT_TYPE, mime::APPLICATION_JSON))

View File

@ -353,7 +353,7 @@ where
/// ``` /// ```
/// use actix_service::Service; /// use actix_service::Service;
/// use actix_web::{middleware, web, App}; /// use actix_web::{middleware, web, App};
/// use actix_web::http::{header::CONTENT_TYPE, HeaderValue}; /// use actix_web::http::header::{CONTENT_TYPE, HeaderValue};
/// ///
/// async fn index() -> &'static str { /// async fn index() -> &'static str {
/// "Welcome!" /// "Welcome!"
@ -410,7 +410,7 @@ where
/// ``` /// ```
/// use actix_service::Service; /// use actix_service::Service;
/// use actix_web::{web, App}; /// use actix_web::{web, App};
/// use actix_web::http::{header::CONTENT_TYPE, HeaderValue}; /// use actix_web::http::header::{CONTENT_TYPE, HeaderValue};
/// ///
/// async fn index() -> &'static str { /// async fn index() -> &'static str {
/// "Welcome!" /// "Welcome!"

View File

@ -37,19 +37,20 @@ type ErrorHandler<B> = dyn Fn(ServiceResponse<B>) -> Result<ErrorHandlerResponse
/// # Examples /// # Examples
/// ``` /// ```
/// use actix_web::middleware::{ErrorHandlers, ErrorHandlerResponse}; /// use actix_web::middleware::{ErrorHandlers, ErrorHandlerResponse};
/// use actix_web::{web, http, dev, App, HttpRequest, HttpResponse, Result}; /// use actix_web::{web, dev, App, HttpRequest, HttpResponse, Result};
/// use actix_web::http::{StatusCode, header};
/// ///
/// fn render_500<B>(mut res: dev::ServiceResponse<B>) -> Result<ErrorHandlerResponse<B>> { /// fn render_500<B>(mut res: dev::ServiceResponse<B>) -> Result<ErrorHandlerResponse<B>> {
/// res.response_mut() /// res.response_mut()
/// .headers_mut() /// .headers_mut()
/// .insert(http::header::CONTENT_TYPE, http::HeaderValue::from_static("Error")); /// .insert(header::CONTENT_TYPE, header::HeaderValue::from_static("Error"));
/// Ok(ErrorHandlerResponse::Response(res)) /// Ok(ErrorHandlerResponse::Response(res))
/// } /// }
/// ///
/// let app = App::new() /// let app = App::new()
/// .wrap( /// .wrap(
/// ErrorHandlers::new() /// ErrorHandlers::new()
/// .handler(http::StatusCode::INTERNAL_SERVER_ERROR, render_500), /// .handler(StatusCode::INTERNAL_SERVER_ERROR, render_500),
/// ) /// )
/// .service(web::resource("/test") /// .service(web::resource("/test")
/// .route(web::get().to(|| HttpResponse::Ok())) /// .route(web::get().to(|| HttpResponse::Ok()))

View File

@ -126,7 +126,8 @@ impl Logger {
/// ///
/// # Example /// # Example
/// ``` /// ```
/// # use actix_web::{http::HeaderValue, middleware::Logger}; /// # use actix_web::http::{header::HeaderValue};
/// # use actix_web::middleware::Logger;
/// # fn parse_jwt_id (_req: Option<&HeaderValue>) -> String { "jwt_uid".to_owned() } /// # fn parse_jwt_id (_req: Option<&HeaderValue>) -> String { "jwt_uid".to_owned() }
/// Logger::new("example %{JWT_ID}xi") /// Logger::new("example %{JWT_ID}xi")
/// .custom_request_replace("JWT_ID", |req| parse_jwt_id(req.headers().get("Authorization"))); /// .custom_request_replace("JWT_ID", |req| parse_jwt_id(req.headers().get("Authorization")));

View File

@ -298,7 +298,7 @@ where
/// ``` /// ```
/// use actix_service::Service; /// use actix_service::Service;
/// use actix_web::{web, App}; /// use actix_web::{web, App};
/// use actix_web::http::{header::CONTENT_TYPE, HeaderValue}; /// use actix_web::http::header::{CONTENT_TYPE, HeaderValue};
/// ///
/// async fn index() -> &'static str { /// async fn index() -> &'static str {
/// "Welcome!" /// "Welcome!"

View File

@ -347,7 +347,7 @@ where
/// ``` /// ```
/// use actix_service::Service; /// use actix_service::Service;
/// use actix_web::{web, App}; /// use actix_web::{web, App};
/// use actix_web::http::{header::CONTENT_TYPE, HeaderValue}; /// use actix_web::http::header::{CONTENT_TYPE, HeaderValue};
/// ///
/// async fn index() -> &'static str { /// async fn index() -> &'static str {
/// "Welcome!" /// "Welcome!"