Add handler.

This commit is contained in:
LukeMathWalker 2021-07-25 16:40:01 +01:00
parent 16ba42dccf
commit 83826d0166
2 changed files with 17 additions and 5 deletions

View file

@ -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<BodyData>) -> HttpResponse {
HttpResponse::Ok().finish() HttpResponse::Ok().finish()
} }

View file

@ -1,5 +1,5 @@
use crate::helpers::{spawn_app, ConfirmationLinks, TestApp}; use crate::helpers::{spawn_app, ConfirmationLinks, TestApp};
use wiremock::matchers::{method, path, any}; use wiremock::matchers::{any, method, path};
use wiremock::{Mock, ResponseTemplate}; use wiremock::{Mock, ResponseTemplate};
async fn create_unconfirmed_subscriber(app: &TestApp) -> ConfirmationLinks { async fn create_unconfirmed_subscriber(app: &TestApp) -> ConfirmationLinks {
@ -51,7 +51,7 @@ async fn newsletters_are_not_delivered_to_unconfirmed_subscribers() {
// Act // Act
let newsletter_request_body = serde_json::json!({ let newsletter_request_body = serde_json::json!({
"title": "Newsletter title", "title": "Newsletter title",
"body": { "content": {
"text": "Newsletter body as plain text", "text": "Newsletter body as plain text",
"html": "<p>Newsletter body as HTML</p>", "html": "<p>Newsletter body as HTML</p>",
} }
@ -84,7 +84,7 @@ async fn newsletters_are_delivered_to_confirmed_subscribers() {
// Act // Act
let newsletter_request_body = serde_json::json!({ let newsletter_request_body = serde_json::json!({
"title": "Newsletter title", "title": "Newsletter title",
"body": { "content": {
"text": "Newsletter body as plain text", "text": "Newsletter body as plain text",
"html": "<p>Newsletter body as HTML</p>", "html": "<p>Newsletter body as HTML</p>",
} }