mirror of
https://github.com/LukeMathWalker/zero-to-production.git
synced 2024-12-18 05:56:35 +00:00
Add handler.
This commit is contained in:
parent
2e644faf9d
commit
16ba42dccf
4 changed files with 11 additions and 4 deletions
|
@ -1,7 +1,9 @@
|
|||
mod health_check;
|
||||
mod newsletters;
|
||||
mod subscriptions;
|
||||
mod subscriptions_confirm;
|
||||
|
||||
pub use health_check::*;
|
||||
pub use newsletters::*;
|
||||
pub use subscriptions::*;
|
||||
pub use subscriptions_confirm::*;
|
||||
|
|
5
src/routes/newsletters.rs
Normal file
5
src/routes/newsletters.rs
Normal file
|
@ -0,0 +1,5 @@
|
|||
use actix_web::HttpResponse;
|
||||
|
||||
pub async fn publish_newsletter() -> HttpResponse {
|
||||
HttpResponse::Ok().finish()
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
use crate::configuration::{DatabaseSettings, Settings};
|
||||
use crate::email_client::EmailClient;
|
||||
use crate::routes::{confirm, health_check, subscribe};
|
||||
use crate::routes::{confirm, health_check, publish_newsletter, subscribe};
|
||||
use actix_web::dev::Server;
|
||||
use actix_web::web::Data;
|
||||
use actix_web::{web, App, HttpServer};
|
||||
|
@ -79,6 +79,7 @@ fn run(
|
|||
.route("/health_check", web::get().to(health_check))
|
||||
.route("/subscriptions", web::post().to(subscribe))
|
||||
.route("/subscriptions/confirm", web::get().to(confirm))
|
||||
.route("/newsletters", web::post().to(publish_newsletter))
|
||||
.app_data(db_pool.clone())
|
||||
.app_data(email_client.clone())
|
||||
.app_data(base_url.clone())
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::helpers::{spawn_app, ConfirmationLinks, TestApp};
|
||||
use wiremock::matchers::{method, path};
|
||||
use wiremock::matchers::{method, path, any};
|
||||
use wiremock::{Mock, ResponseTemplate};
|
||||
|
||||
async fn create_unconfirmed_subscriber(app: &TestApp) -> ConfirmationLinks {
|
||||
|
@ -42,8 +42,7 @@ async fn newsletters_are_not_delivered_to_unconfirmed_subscribers() {
|
|||
let app = spawn_app().await;
|
||||
create_unconfirmed_subscriber(&app).await;
|
||||
|
||||
Mock::given(path("/email"))
|
||||
.and(method("POST"))
|
||||
Mock::given(any())
|
||||
.respond_with(ResponseTemplate::new(200))
|
||||
.expect(0)
|
||||
.mount(&app.email_server)
|
||||
|
|
Loading…
Reference in a new issue