From 83826d01660bc765c3151115e7d9c5ed20081b12 Mon Sep 17 00:00:00 2001 From: LukeMathWalker Date: Sun, 25 Jul 2021 16:40:01 +0100 Subject: [PATCH] Add handler. --- src/routes/newsletters.rs | 16 ++++++++++++++-- tests/api/newsletter.rs | 6 +++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/routes/newsletters.rs b/src/routes/newsletters.rs index aba10ad..84df182 100644 --- a/src/routes/newsletters.rs +++ b/src/routes/newsletters.rs @@ -1,5 +1,17 @@ -use actix_web::HttpResponse; +use actix_web::{web, HttpResponse}; -pub async fn publish_newsletter() -> HttpResponse { +#[derive(serde::Serialize)] +pub struct BodyData { + title: String, + content: Content, +} + +#[derive(serde::Serialize)] +pub struct Content { + html: String, + text: String, +} + +pub async fn publish_newsletter(_body: web::Json) -> HttpResponse { HttpResponse::Ok().finish() } diff --git a/tests/api/newsletter.rs b/tests/api/newsletter.rs index 9ad5fcf..576aa14 100644 --- a/tests/api/newsletter.rs +++ b/tests/api/newsletter.rs @@ -1,5 +1,5 @@ use crate::helpers::{spawn_app, ConfirmationLinks, TestApp}; -use wiremock::matchers::{method, path, any}; +use wiremock::matchers::{any, method, path}; use wiremock::{Mock, ResponseTemplate}; async fn create_unconfirmed_subscriber(app: &TestApp) -> ConfirmationLinks { @@ -51,7 +51,7 @@ async fn newsletters_are_not_delivered_to_unconfirmed_subscribers() { // Act let newsletter_request_body = serde_json::json!({ "title": "Newsletter title", - "body": { + "content": { "text": "Newsletter body as plain text", "html": "

Newsletter body as HTML

", } @@ -84,7 +84,7 @@ async fn newsletters_are_delivered_to_confirmed_subscribers() { // Act let newsletter_request_body = serde_json::json!({ "title": "Newsletter title", - "body": { + "content": { "text": "Newsletter body as plain text", "html": "

Newsletter body as HTML

", }