mirror of
https://github.com/LukeMathWalker/zero-to-production.git
synced 2024-12-18 14:06:37 +00:00
Ensure consistency of variable naming.
This commit is contained in:
parent
1a4ead9b74
commit
d21c36f74f
2 changed files with 12 additions and 12 deletions
|
@ -10,7 +10,7 @@ pub struct FormData {
|
|||
}
|
||||
|
||||
pub async fn subscribe(
|
||||
payload: web::Form<FormData>,
|
||||
form: web::Form<FormData>,
|
||||
pool: web::Data<PgPool>,
|
||||
) -> Result<HttpResponse, HttpResponse> {
|
||||
sqlx::query!(
|
||||
|
@ -19,8 +19,8 @@ pub async fn subscribe(
|
|||
VALUES ($1, $2, $3, $4)
|
||||
"#,
|
||||
Uuid::new_v4(),
|
||||
payload.email,
|
||||
payload.name,
|
||||
form.email,
|
||||
form.name,
|
||||
Utc::now()
|
||||
)
|
||||
.execute(pool.as_ref())
|
||||
|
|
|
@ -11,17 +11,17 @@ pub struct FormData {
|
|||
|
||||
#[tracing::instrument(
|
||||
name = "Adding a new subscriber",
|
||||
skip(payload, pool),
|
||||
skip(form, pool),
|
||||
fields(
|
||||
email = %payload.email,
|
||||
name = %payload.name
|
||||
email = %form.email,
|
||||
name = %form.name
|
||||
)
|
||||
)]
|
||||
pub async fn subscribe(
|
||||
payload: web::Form<FormData>,
|
||||
form: web::Form<FormData>,
|
||||
pool: web::Data<PgPool>,
|
||||
) -> Result<HttpResponse, HttpResponse> {
|
||||
insert_subscriber(&pool, &payload)
|
||||
insert_subscriber(&pool, &form)
|
||||
.await
|
||||
.map_err(|_| HttpResponse::InternalServerError().finish())?;
|
||||
Ok(HttpResponse::Ok().finish())
|
||||
|
@ -29,17 +29,17 @@ pub async fn subscribe(
|
|||
|
||||
#[tracing::instrument(
|
||||
name = "Saving new subscriber details in the database",
|
||||
skip(payload, pool)
|
||||
skip(form, pool)
|
||||
)]
|
||||
pub async fn insert_subscriber(pool: &PgPool, payload: &FormData) -> Result<(), sqlx::Error> {
|
||||
pub async fn insert_subscriber(pool: &PgPool, form: &FormData) -> Result<(), sqlx::Error> {
|
||||
sqlx::query!(
|
||||
r#"
|
||||
INSERT INTO subscriptions (id, email, name, subscribed_at)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
"#,
|
||||
Uuid::new_v4(),
|
||||
payload.email,
|
||||
payload.name,
|
||||
form.email,
|
||||
form.name,
|
||||
Utc::now()
|
||||
)
|
||||
.execute(pool)
|
||||
|
|
Loading…
Reference in a new issue