aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index ab03fb3..6ebe145 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,6 +2,7 @@ mod config;
mod errors;
mod handlers;
mod models;
+mod utils;
use std::{net::SocketAddr, str::FromStr, sync::Arc, time::Duration};
@@ -13,6 +14,8 @@ use axum_extra::extract::{PrivateCookieJar, SignedCookieJar};
use axum_extra::extract::cookie::Key;
use errors::{StringResult, HtmlResult};
use hyper::StatusCode;
+use models::{Peer, Network};
+use sqlx::query_as;
use sqlx::{PgPool, postgres::PgPoolOptions};
use tower::ServiceBuilder;
use tower_http::trace::TraceLayer;
@@ -106,8 +109,12 @@ async fn index(state: Extension<Arc<State>>, jar: PrivateCookieJar) -> HtmlResul
Ok(u) => Some(u),
Err(_) => None,
};
+
+ let peers: Vec<Peer> = query_as("SELECT * FROM peers").fetch_all(&mut conn).await?;
+ let nets: Vec<Network> = query_as("SELECT * FROM networks").fetch_all(&mut conn).await?;
+
let mut buf = Vec::new();
- crate::templates::index_html(&mut buf, user).unwrap();
+ crate::templates::index_html(&mut buf, user, peers, nets).unwrap();
match String::from_utf8(buf) {
Ok(s) => Ok(Html(s)),
@@ -115,6 +122,12 @@ async fn index(state: Extension<Arc<State>>, jar: PrivateCookieJar) -> HtmlResul
}
}
+async fn test_email() -> Result<(), ServiceError> {
+ utils::send_email("csalter@carathe.dev".to_string(), "Test Email".to_string(), "Hi, test".to_string()).await?;
+
+ Ok(())
+}
+
async fn statics(Path(name): Path<String>) -> Result<Response, ServiceError> {
for s in templates::statics::STATICS {
trace!("Name: {}\nContents:\n{:?}\n\n", s.name, s.content);