-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,7 @@ pub mod user { | |
pub mod service; | ||
pub mod views; | ||
} | ||
|
||
pub mod web { | ||
pub mod handlers; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use askama::Template; | ||
use axum::http::StatusCode; | ||
use axum::response::{Html, IntoResponse, Response}; | ||
|
||
pub async fn index() -> impl IntoResponse { | ||
let template = IndexTemplate {}; | ||
HtmlTemplate(template) | ||
} | ||
|
||
#[derive(Template)] | ||
#[template(path = "index.html")] | ||
struct IndexTemplate; | ||
|
||
struct HtmlTemplate<T>(T); | ||
|
||
impl<T> IntoResponse for HtmlTemplate<T> | ||
where | ||
T: Template, | ||
{ | ||
fn into_response(self) -> Response { | ||
match self.0.render() { | ||
Ok(html) => Html(html).into_response(), | ||
Err(err) => ( | ||
StatusCode::INTERNAL_SERVER_ERROR, | ||
format!("Failed to render template. Error: {}", err), | ||
) | ||
.into_response(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<body> | ||
<h1>Todo App</h1> | ||
<p>Index page</p> | ||
</body> | ||
</html> |