mirror of https://github.com/fafhrd91/actix-web
fix doctest refs
This commit is contained in:
parent
d39c2a89b2
commit
040bcb0bf0
|
@ -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))
|
||||||
|
|
|
@ -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!"
|
||||||
|
|
|
@ -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()))
|
||||||
|
|
|
@ -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")));
|
||||||
|
|
|
@ -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!"
|
||||||
|
|
|
@ -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!"
|
||||||
|
|
Loading…
Reference in New Issue