Add in framework for post requests for user subscriptions
Complete up to page 45
This commit is contained in:
+16
-5
@@ -6,12 +6,23 @@ 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))
|
||||
})
|
||||
.listen(listener)?
|
||||
.run();
|
||||
App::new()
|
||||
.route("/health_check", web::get().to(health_check))
|
||||
.route("/subscriptions", web::post().to(subscribe))
|
||||
})
|
||||
.listen(listener)?
|
||||
.run();
|
||||
Ok(server)
|
||||
}
|
||||
Reference in New Issue
Block a user