mirror of
https://github.com/LukeMathWalker/zero-to-production.git
synced 2024-11-25 02:01:03 +00:00
Add handler.
This commit is contained in:
parent
16ba42dccf
commit
83826d0166
2 changed files with 17 additions and 5 deletions
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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": "<p>Newsletter body as HTML</p>",
|
||||
}
|
||||
|
@ -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": "<p>Newsletter body as HTML</p>",
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue