mirror of
https://github.com/LukeMathWalker/zero-to-production.git
synced 2024-12-18 22:16:40 +00:00
Register email client.
This commit is contained in:
parent
b7634725db
commit
d8048db840
1 changed files with 8 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
use crate::email_client::EmailClient;
|
||||||
use crate::routes::{health_check, subscribe};
|
use crate::routes::{health_check, subscribe};
|
||||||
use actix_web::dev::Server;
|
use actix_web::dev::Server;
|
||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
|
@ -6,14 +7,20 @@ use sqlx::PgPool;
|
||||||
use std::net::TcpListener;
|
use std::net::TcpListener;
|
||||||
use tracing_actix_web::TracingLogger;
|
use tracing_actix_web::TracingLogger;
|
||||||
|
|
||||||
pub fn run(listener: TcpListener, db_pool: PgPool) -> Result<Server, std::io::Error> {
|
pub fn run(
|
||||||
|
listener: TcpListener,
|
||||||
|
db_pool: PgPool,
|
||||||
|
email_client: EmailClient,
|
||||||
|
) -> Result<Server, std::io::Error> {
|
||||||
let db_pool = Data::new(db_pool);
|
let db_pool = Data::new(db_pool);
|
||||||
|
let email_client = Data::new(email_client);
|
||||||
let server = HttpServer::new(move || {
|
let server = HttpServer::new(move || {
|
||||||
App::new()
|
App::new()
|
||||||
.wrap(TracingLogger)
|
.wrap(TracingLogger)
|
||||||
.route("/health_check", web::get().to(health_check))
|
.route("/health_check", web::get().to(health_check))
|
||||||
.route("/subscriptions", web::post().to(subscribe))
|
.route("/subscriptions", web::post().to(subscribe))
|
||||||
.app_data(db_pool.clone())
|
.app_data(db_pool.clone())
|
||||||
|
.app_data(email_client.clone())
|
||||||
})
|
})
|
||||||
.listen(listener)?
|
.listen(listener)?
|
||||||
.run();
|
.run();
|
||||||
|
|
Loading…
Reference in a new issue