From d21c36f74fe448fa6358f2a9b12aae897004291f Mon Sep 17 00:00:00 2001 From: LukeMathWalker Date: Sun, 18 Oct 2020 14:35:08 +0100 Subject: [PATCH] Ensure consistency of variable naming. --- chapter03-1/src/routes/subscriptions.rs | 6 +++--- chapter04/src/routes/subscriptions.rs | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/chapter03-1/src/routes/subscriptions.rs b/chapter03-1/src/routes/subscriptions.rs index 8a79ec6..8db4b58 100644 --- a/chapter03-1/src/routes/subscriptions.rs +++ b/chapter03-1/src/routes/subscriptions.rs @@ -10,7 +10,7 @@ pub struct FormData { } pub async fn subscribe( - payload: web::Form, + form: web::Form, pool: web::Data, ) -> Result { 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()) diff --git a/chapter04/src/routes/subscriptions.rs b/chapter04/src/routes/subscriptions.rs index 052270c..fd801af 100644 --- a/chapter04/src/routes/subscriptions.rs +++ b/chapter04/src/routes/subscriptions.rs @@ -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, + form: web::Form, pool: web::Data, ) -> Result { - 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)