summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWriterV2 <primary-v2@protonmail.com>2024-08-10 19:23:25 +0200
committerWriterV2 <primary-v2@protonmail.com>2024-08-10 19:23:25 +0200
commitd1dc5d0d652030847e8ee593bf4007e6ffefaf1a (patch)
tree5476b778021be0769763cd99806c7a89f37e7b8c
parentf982a5621bfed646ce71fcf7aeeca71ef4ae55c1 (diff)
Feat: Add empty home route
-rw-r--r--Cargo.toml7
-rw-r--r--src/main.rs40
2 files changed, 40 insertions, 7 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 7835f72..8fd7c21 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,9 +6,8 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-tera = "1.17"
serde = {version = "1.0", features = ["derive"]}
-serde_json = "1.0"
anyhow = "1.0"
-chrono = {version = "0.4", features = ["serde"]}
-pdf = "=0.8.0"
+tokio = { version = "1.39.2", features = ["full"] }
+maud = { version = "0.26.0", features = ["axum"] }
+axum = "0.7.5"
diff --git a/src/main.rs b/src/main.rs
index 37f1399..7936364 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,5 +1,39 @@
-use anyhow::Result;
+use axum::http::StatusCode;
+use axum::response::IntoResponse;
+use axum::routing::get;
+use axum::Router;
+use maud::html;
-fn main() -> Result<()> {
- Ok(())
+struct AppError(anyhow::Error);
+
+impl IntoResponse for AppError {
+ fn into_response(self) -> axum::response::Response {
+ (
+ StatusCode::INTERNAL_SERVER_ERROR,
+ format!("Something went wrong: {}", self.0),
+ )
+ .into_response()
+ }
+}
+
+impl<E> From<E> for AppError
+where
+ E: Into<anyhow::Error>,
+{
+ fn from(err: E) -> Self {
+ Self(err.into())
+ }
+}
+
+#[tokio::main]
+async fn main() {
+ let app = Router::new().route("/", get(home));
+ let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
+ axum::serve(listener, app.into_make_service())
+ .await
+ .unwrap();
+}
+
+async fn home() -> Result<impl IntoResponse, AppError> {
+ Ok(html!({}))
}