aboutsummaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/actix.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/bin/actix.rs b/src/bin/actix.rs
index 3f00f36..101fe2e 100644
--- a/src/bin/actix.rs
+++ b/src/bin/actix.rs
@@ -1,6 +1,7 @@
use actix_web::{get, web, middleware, App, HttpResponse, HttpServer, Responder, http::header::ContentType};
use macroblog::blog::{render_index_page, render_post_page};
-use std::{env};
+use macroblog::router::blog_post_exists;
+use std::env;
#[get("/")]
async fn index() -> impl Responder {
@@ -14,6 +15,12 @@ async fn index() -> impl Responder {
#[get("/posts/{name}")]
async fn posts(name: web::Path<String>) -> impl Responder {
+
+ if !blog_post_exists(&name) {
+ return HttpResponse::NotFound()
+ .body("Not Found".to_string());
+ }
+
let body = render_post_page(&name);
HttpResponse::Ok()