Up until the database, need to get docker and CI/CD on server first

This commit is contained in:
2024-04-08 09:08:50 +02:00
parent 298cc67e2d
commit 11aadb64bf
4 changed files with 0 additions and 0 deletions

28
src/lib.rs Normal file
View File

@@ -0,0 +1,28 @@
use actix_web::{dev::Server, web, App, HttpResponse, HttpServer};
use std::net::TcpListener;
async fn health_check() -> HttpResponse {
HttpResponse::Ok().finish()
}
#[derive(serde::Deserialize)]
struct FormData {
email: String,
name: String,
}
async fn subscribe(_form: web::Form<FormData>) -> HttpResponse {
HttpResponse::Ok().finish()
}
pub fn run(listener: TcpListener) -> Result<Server, std::io::Error> {
let server = HttpServer::new(|| {
App::new()
.route("/health_check", web::get().to(health_check))
.route("/subscriptions", web::post().to(subscribe))
})
.listen(listener)?
.run();
Ok(server)
}

10
src/main.rs Normal file
View File

@@ -0,0 +1,10 @@
use std::net::TcpListener;
use email_newsletter::run;
#[tokio::main]
async fn main() -> Result<(), std::io::Error> {
let listener = TcpListener::bind("127.0.0.1:0").expect("Failed to bind to address");
run(listener)?.await
}