mirror of
https://github.com/LukeMathWalker/zero-to-production.git
synced 2024-12-18 05:56:35 +00:00
Do not change struct name.
This commit is contained in:
parent
ff99488030
commit
1a4ead9b74
2 changed files with 5 additions and 8 deletions
|
@ -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<SubscribeRequest>,
|
||||
payload: web::Form<FormData>,
|
||||
pool: web::Data<PgPool>,
|
||||
) -> Result<HttpResponse, HttpResponse> {
|
||||
sqlx::query!(
|
||||
|
|
|
@ -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<SubscribeRequest>,
|
||||
payload: web::Form<FormData>,
|
||||
pool: web::Data<PgPool>,
|
||||
) -> Result<HttpResponse, HttpResponse> {
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue