mirror of
https://github.com/LukeMathWalker/zero-to-production.git
synced 2024-11-27 03:21:08 +00:00
Update to latest actix-web
This commit is contained in:
parent
0139d7a148
commit
18a1ff9d59
3 changed files with 322 additions and 244 deletions
535
Cargo.lock
generated
535
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
10
Cargo.toml
10
Cargo.toml
|
@ -13,13 +13,11 @@ path = "src/main.rs"
|
|||
name = "zero2prod"
|
||||
|
||||
[dependencies]
|
||||
actix-http = "=3.0.0-beta.5"
|
||||
actix-service = "=2.0.0-beta.5"
|
||||
actix-web = "=4.0.0-beta.5"
|
||||
|
||||
actix-web = "=4.0.0-beta.8"
|
||||
actix-http = "=3.0.0-beta.8"
|
||||
serde = "1.0.115"
|
||||
config = { version = "0.10.1", default-features = false, features = ["yaml"] }
|
||||
sqlx = { version = "0.5.1", default-features = false, features = [ "runtime-actix-rustls", "macros", "postgres", "uuid", "chrono", "migrate", "offline"] }
|
||||
sqlx = { version = "0.5.5", default-features = false, features = [ "runtime-actix-rustls", "macros", "postgres", "uuid", "chrono", "migrate"] }
|
||||
uuid = { version = "0.8.1", features = ["v4"] }
|
||||
chrono = "0.4.15"
|
||||
tracing = "0.1.19"
|
||||
|
@ -30,7 +28,7 @@ tracing-log = "0.1.1"
|
|||
serde-aux = "1.0.1"
|
||||
unicode-segmentation = "1.7.1"
|
||||
validator = "0.12.0"
|
||||
tracing-actix-web = "0.4.0-beta.4"
|
||||
tracing-actix-web = "0.4.0-beta.8"
|
||||
|
||||
[dev-dependencies]
|
||||
reqwest = { version = "0.11", features = ["json"] }
|
||||
|
|
|
@ -29,18 +29,15 @@ impl TryInto<NewSubscriber> for FormData {
|
|||
name = %form.name
|
||||
)
|
||||
)]
|
||||
pub async fn subscribe(
|
||||
form: web::Form<FormData>,
|
||||
pool: web::Data<PgPool>,
|
||||
) -> Result<HttpResponse, HttpResponse> {
|
||||
let new_subscriber = form
|
||||
.0
|
||||
.try_into()
|
||||
.map_err(|_| HttpResponse::BadRequest().finish())?;
|
||||
insert_subscriber(&pool, &new_subscriber)
|
||||
.await
|
||||
.map_err(|_| HttpResponse::InternalServerError().finish())?;
|
||||
Ok(HttpResponse::Ok().finish())
|
||||
pub async fn subscribe(form: web::Form<FormData>, pool: web::Data<PgPool>) -> HttpResponse {
|
||||
let new_subscriber = match form.0.try_into() {
|
||||
Ok(form) => form,
|
||||
Err(_) => return HttpResponse::BadRequest().finish(),
|
||||
};
|
||||
match insert_subscriber(&pool, &new_subscriber).await {
|
||||
Ok(_) => HttpResponse::Ok().finish(),
|
||||
Err(_) => HttpResponse::InternalServerError().finish(),
|
||||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(
|
||||
|
|
Loading…
Reference in a new issue