diff options
Diffstat (limited to 'src/pages')
-rw-r--r-- | src/pages/mod.rs | 1 | ||||
-rw-r--r-- | src/pages/p404.rs | 13 | ||||
-rw-r--r-- | src/pages/repo/about.rs | 7 |
3 files changed, 17 insertions, 4 deletions
diff --git a/src/pages/mod.rs b/src/pages/mod.rs index 9de9d47..d53561b 100644 --- a/src/pages/mod.rs +++ b/src/pages/mod.rs @@ -4,3 +4,4 @@ //! which is exported from the module and then called by the router pub mod repo; +pub mod p404; diff --git a/src/pages/p404.rs b/src/pages/p404.rs new file mode 100644 index 0000000..6427a19 --- /dev/null +++ b/src/pages/p404.rs @@ -0,0 +1,13 @@ +use actix_web::{HttpResponse, Result}; +use askama::Template; + +#[derive(Template)] +#[template(path = "404.html")] +struct P404; + +/// Render a simple 404 page +pub async fn render() -> Result<HttpResponse> { + Ok(HttpResponse::NotFound() + .content_type("text/html") + .body(P404.render().unwrap())) +} diff --git a/src/pages/repo/about.rs b/src/pages/repo/about.rs index adfa46e..8797edd 100644 --- a/src/pages/repo/about.rs +++ b/src/pages/repo/about.rs @@ -1,5 +1,3 @@ -//! The "repository/about" subpage - use actix_web::{web, HttpRequest, HttpResponse, Result}; use askama::Template; @@ -16,7 +14,8 @@ struct Repo<'a> { num_contributors: usize, } -pub fn render(req: HttpRequest, path: web::Path<(String)>) -> Result<HttpResponse> { +/// Renders the "repository/about" subpage +pub async fn render(req: HttpRequest, path: web::Path<String>) -> Result<HttpResponse> { println!("Rendering path: {:#?}", path); dbg!(req); @@ -31,6 +30,6 @@ pub fn render(req: HttpRequest, path: web::Path<(String)>) -> Result<HttpRespons num_contributors: 3, } .render() - .unwrap(); + .unwrap(); Ok(HttpResponse::Ok().content_type("text/html").body(repo)) } |