Everything up until serde

This commit is contained in:
2024-04-03 16:51:31 +02:00
parent df6b3db5c2
commit 298cc67e2d
4 changed files with 130 additions and 0 deletions

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)
}