tanguy.gerome.fi/src/main.rs

43 lines
1.3 KiB
Rust
Raw Normal View History

2024-10-21 19:40:51 +03:00
#[cfg(feature = "ssr")]
#[tokio::main]
async fn main() {
2024-11-09 22:49:25 +02:00
if cfg!(debug_assertions) {
let _ = dotenvy::dotenv();
}
2024-10-21 19:40:51 +03:00
use axum::Router;
use leptos::logging::log;
use leptos::prelude::*;
2024-10-21 19:40:51 +03:00
use leptos_axum::{generate_route_list, LeptosRoutes};
use tanguy_gerome_fi::app::*;
let conf = get_configuration(None).unwrap();
let addr = conf.leptos_options.site_addr;
2024-10-21 19:40:51 +03:00
let leptos_options = conf.leptos_options;
// Generate the list of routes in your Leptos App
2024-10-21 19:40:51 +03:00
let routes = generate_route_list(App);
let app = Router::new()
.leptos_routes(&leptos_options, routes, {
let leptos_options = leptos_options.clone();
move || shell(leptos_options.clone())
})
.fallback(leptos_axum::file_and_error_handler(shell))
2024-10-21 19:40:51 +03:00
.with_state(leptos_options);
// run our app with hyper
// `axum::Server` is a re-export of `hyper::Server`
log!("listening on http://{}", &addr);
2024-10-21 19:40:51 +03:00
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
axum::serve(listener, app.into_make_service())
.await
.unwrap();
}
#[cfg(not(feature = "ssr"))]
pub fn main() {
// no client-side main function
// unless we want this to work with e.g., Trunk for pure client-side testing
2024-10-21 19:40:51 +03:00
// see lib.rs for hydration function instead
}