MCPcopy Create free account
hub / github.com/PerroEngine/Perro / main

Function main

perro_website/src/main.rs:3–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1#[cfg(feature = "ssr")]
2#[tokio::main]
3async fn main() -> Result<(), Box<dyn std::error::Error>> {
4 use axum::{routing::get, Router};
5 use leptos::config::get_configuration;
6 use leptos_axum::{generate_route_list, LeptosRoutes};
7 use perro_website_lib::App;
8 use tower_http::services::{ServeDir, ServeFile};
9
10 tracing_subscriber::fmt().with_env_filter("info").init();
11
12 let conf = get_configuration(Some("perro_website/Cargo.toml"))?;
13 let leptos_options = conf.leptos_options;
14 let addr = leptos_options.site_addr;
15 let routes = generate_route_list(App);
16 let site_root = std::path::PathBuf::from(leptos_options.site_root.as_ref());
17 let crate_root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
18 let public_root = crate_root.join("public");
19 let style_root = crate_root.join("style");
20
21 let app = Router::new()
22 .nest_service("/style", ServeDir::new(style_root))
23 .nest_service("/demos", ServeDir::new(public_root.join("demos")))
24 .nest_service("/tiers", ServeDir::new(public_root.join("tiers")))
25 .route_service("/perro.svg", ServeFile::new(public_root.join("perro.svg")))
26 .route("/robots.txt", get(robots_txt))
27 .route("/sitemap.xml", get(sitemap_xml))
28 .route("/og/{*path}", get(og_image))
29 .leptos_routes(&leptos_options, routes, App)
30 .fallback_service(ServeDir::new(site_root))
31 .with_state(leptos_options);
32
33 let listener = tokio::net::TcpListener::bind(&addr).await?;
34 tracing::info!("perro_website @ http://{addr}");
35 axum::serve(listener, app.into_make_service()).await?;
36 Ok(())
37}
38
39#[cfg(feature = "ssr")]
40async fn og_image(
41 axum::extract::Path(path): axum::extract::Path<String>,

Callers

nothing calls this directly

Calls 4

joinMethod · 0.80
getFunction · 0.50
as_refMethod · 0.45
with_stateMethod · 0.45

Tested by

no test coverage detected