feat(server): working friend page

This commit is contained in:
Maieul BOYER 2026-02-08 23:34:44 +01:00
parent 83433186f3
commit 0b17c760cb
Signed by: maix
SSH key fingerprint: SHA256:iqCzqFFF5KjRixmDExqbAltCIj9ndlBWIGJf3t9Ln9g
2126 changed files with 35620 additions and 42 deletions

View file

@ -31,25 +31,25 @@
*/
use std::sync::Arc;
use axum::Router;
use log::info;
use tower_http::trace::TraceLayer;
use tracing_subscriber::EnvFilter;
mod friends;
mod state;
mod static_;
mod user;
#[derive(Clone, Debug)]
struct GlobalState {
templates: Arc<minijinja::Environment<'static>>,
pub use state::GlobalState;
pub fn report_error(err: color_eyre::Report) {
log::error!("Got an error: {err:?}");
}
#[tokio::main]
async fn main() {
tracing_subscriber::fmt()
// This allows you to use, e.g., `RUST_LOG=info` or `RUST_LOG=debug`
// when running the app to set log levels.
.with_env_filter(
EnvFilter::try_from_default_env()
.or_else(|_| EnvFilter::try_new("froxy_server=error,tower_http=warn"))
@ -57,15 +57,12 @@ async fn main() {
)
.init();
let mut env = minijinja::Environment::new();
froxy_templates::friends::add_to_context(&mut env);
let global_state = GlobalState {
templates: Arc::new(env),
};
let global_state = GlobalState::new();
let app = Router::new()
.merge(friends::router())
.merge(user::router())
.merge(static_::router(&global_state))
.with_state(global_state)
.layer(TraceLayer::new_for_http());
@ -74,6 +71,6 @@ async fn main() {
info!("Starting server on {ip}:{port}");
// run our app with hyper, listening globally on port 3000
let listener = tokio::net::TcpListener::bind((ip,port)).await.unwrap();
let listener = tokio::net::TcpListener::bind((ip, port)).await.unwrap();
axum::serve(listener, app).await.unwrap();
}