Ensure consistency of variable naming.

This commit is contained in:
LukeMathWalker 2020-10-18 14:35:08 +01:00
parent 1a4ead9b74
commit d21c36f74f
2 changed files with 12 additions and 12 deletions

View file

@ -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())

View file

@ -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)