Update to actix-web v4

This commit is contained in:
Luca P 2022-02-25 23:56:02 +00:00
parent 9a858dade4
commit 4c86217f2b
3 changed files with 369 additions and 291 deletions

652
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -13,7 +13,7 @@ path = "src/main.rs"
name = "zero2prod" name = "zero2prod"
[dependencies] [dependencies]
actix-web = "=4.0.0-beta.19" actix-web = "4"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] } tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
serde = "1.0.115" serde = "1.0.115"
config = { version = "0.11", default-features = false, features = ["yaml"] } config = { version = "0.11", default-features = false, features = ["yaml"] }
@ -34,7 +34,7 @@ rand = { version = "0.8", features=["std_rng"] }
anyhow = "1.0.40" anyhow = "1.0.40"
base64 = "0.13.0" base64 = "0.13.0"
argon2 = { version = "0.3", features = ["std"] } argon2 = { version = "0.3", features = ["std"] }
tracing-actix-web = "=0.5.0-beta.9" tracing-actix-web = "0.5"
secrecy = { version = "0.8", features = ["serde"] } secrecy = { version = "0.8", features = ["serde"] }
[dev-dependencies] [dev-dependencies]

View file

@ -6,7 +6,7 @@ use actix_web::http::{
header::{HeaderMap, HeaderValue}, header::{HeaderMap, HeaderValue},
StatusCode, StatusCode,
}; };
use actix_web::{web, HttpResponse, ResponseError}; use actix_web::{web, HttpResponse, HttpRequest, ResponseError};
use anyhow::Context; use anyhow::Context;
use argon2::{Argon2, PasswordHash, PasswordVerifier}; use argon2::{Argon2, PasswordHash, PasswordVerifier};
use secrecy::{ExposeSecret, Secret}; use secrecy::{ExposeSecret, Secret};
@ -174,7 +174,7 @@ pub async fn publish_newsletter(
body: web::Json<BodyData>, body: web::Json<BodyData>,
pool: web::Data<PgPool>, pool: web::Data<PgPool>,
email_client: web::Data<EmailClient>, email_client: web::Data<EmailClient>,
request: web::HttpRequest, request: HttpRequest,
) -> Result<HttpResponse, PublishError> { ) -> Result<HttpResponse, PublishError> {
let credentials = basic_authentication(request.headers()).map_err(PublishError::AuthError)?; let credentials = basic_authentication(request.headers()).map_err(PublishError::AuthError)?;
tracing::Span::current().record("username", &tracing::field::display(&credentials.username)); tracing::Span::current().record("username", &tracing::field::display(&credentials.username));