diff --git a/chapter03-1/src/routes/subscriptions.rs b/chapter03-1/src/routes/subscriptions.rs index f9f32f4..8a79ec6 100644 --- a/chapter03-1/src/routes/subscriptions.rs +++ b/chapter03-1/src/routes/subscriptions.rs @@ -4,13 +4,13 @@ use sqlx::PgPool; use uuid::Uuid; #[derive(serde::Deserialize)] -pub struct SubscribeRequest { +pub struct FormData { email: String, name: String, } pub async fn subscribe( - payload: web::Form, + payload: web::Form, pool: web::Data, ) -> Result { sqlx::query!( diff --git a/chapter04/src/routes/subscriptions.rs b/chapter04/src/routes/subscriptions.rs index 174c36a..052270c 100644 --- a/chapter04/src/routes/subscriptions.rs +++ b/chapter04/src/routes/subscriptions.rs @@ -4,7 +4,7 @@ use sqlx::PgPool; use uuid::Uuid; #[derive(serde::Deserialize)] -pub struct SubscribeRequest { +pub struct FormData { email: String, name: String, } @@ -18,7 +18,7 @@ pub struct SubscribeRequest { ) )] pub async fn subscribe( - payload: web::Form, + payload: web::Form, pool: web::Data, ) -> Result { insert_subscriber(&pool, &payload) @@ -31,10 +31,7 @@ pub async fn subscribe( name = "Saving new subscriber details in the database", skip(payload, pool) )] -pub async fn insert_subscriber( - pool: &PgPool, - payload: &SubscribeRequest, -) -> Result<(), sqlx::Error> { +pub async fn insert_subscriber(pool: &PgPool, payload: &FormData) -> Result<(), sqlx::Error> { sqlx::query!( r#" INSERT INTO subscriptions (id, email, name, subscribed_at)