mirror of
https://github.com/LukeMathWalker/zero-to-production.git
synced 2024-12-11 18:46:33 +00:00
Update to latest actix-web
This commit is contained in:
parent
b5faa745f1
commit
203a796cfe
3 changed files with 317 additions and 239 deletions
525
Cargo.lock
generated
525
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"
|
||||
reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
|
||||
|
@ -31,7 +29,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]
|
||||
once_cell = "1.7.2"
|
||||
|
|
|
@ -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