mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 14:54:16 +00:00
Minor fixes and revisions
This commit is contained in:
parent
6576d8eda1
commit
6603c44ce2
7 changed files with 7 additions and 10 deletions
|
@ -23,7 +23,7 @@ pub fn App(cx: Scope) -> impl IntoView {
|
|||
<Routes>
|
||||
<Route path="users/:id" view=|cx| view! { cx, <User/> }/>
|
||||
<Route path="stories/:id" view=|cx| view! { cx, <Story/> }/>
|
||||
<Route path="/" view=|cx| view! { cx, <Stories/> }/>
|
||||
<Route path=":stories?" view=|cx| view! { cx, <Stories/> }/>
|
||||
</Routes>
|
||||
</main>
|
||||
</Router>
|
||||
|
|
|
@ -22,7 +22,6 @@ cfg_if! {
|
|||
// Generate the list of routes in your Leptos App
|
||||
let routes = generate_route_list(|cx| view! { cx, <App/> });
|
||||
|
||||
|
||||
HttpServer::new(move || {
|
||||
let leptos_options = &conf.leptos_options;
|
||||
let site_root = &leptos_options.site_root;
|
||||
|
|
|
@ -13,12 +13,12 @@ if #[cfg(feature = "ssr")] {
|
|||
use std::sync::Arc;
|
||||
use leptos::LeptosOptions;
|
||||
|
||||
pub async fn file_handler(Path(file_path): Path<String>, Extension(options): Extension<Arc<LeptosOptions>>) -> Result<Response<BoxBody>, (StatusCode, String)> {
|
||||
pub async fn file_handler(uri: Uri, Extension(options): Extension<Arc<LeptosOptions>>) -> Result<Response<BoxBody>, (StatusCode, String)> {
|
||||
|
||||
let options = &*options;
|
||||
// URIs need the leading slash
|
||||
let full_path = format!("/{file_path}");
|
||||
let uri = Uri::from_str(&full_path).unwrap();
|
||||
// let full_path = format!("/{file_path}");
|
||||
// let uri = Uri::from_str(&full_path).unwrap();
|
||||
let root = options.site_root.clone();
|
||||
let res = get_static_file(uri.clone(), &root).await?;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ pub fn App(cx: Scope) -> impl IntoView {
|
|||
<Routes>
|
||||
<Route path="users/:id" view=|cx| view! { cx, <User/> }/>
|
||||
<Route path="stories/:id" view=|cx| view! { cx, <Story/> }/>
|
||||
<Route path="/" view=|cx| view! { cx, <Stories/> }/>
|
||||
<Route path=":stories?" view=|cx| view! { cx, <Stories/> }/>
|
||||
</Routes>
|
||||
</main>
|
||||
</Router>
|
||||
|
|
|
@ -27,7 +27,7 @@ if #[cfg(feature = "ssr")] {
|
|||
// build our application with a route
|
||||
let app = Router::new()
|
||||
.leptos_routes(leptos_options.clone(), routes, |cx| view! { cx, <App/> } )
|
||||
.route("/*file_path", get(file_handler))
|
||||
.fallback(file_handler)
|
||||
.layer(Extension(Arc::new(leptos_options)));
|
||||
|
||||
// run our app with hyper
|
||||
|
|
|
@ -11,8 +11,6 @@ if #[cfg(feature = "ssr")] {
|
|||
use crate::todo::*;
|
||||
use todo_app_sqlite_axum::*;
|
||||
use crate::file::file_handler;
|
||||
use http::StatusCode;
|
||||
use tower_http::services::ServeDir;
|
||||
use leptos_axum::{generate_route_list, LeptosRoutes};
|
||||
use std::sync::Arc;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ pub struct LeptosOptions {
|
|||
#[builder(setter(into))]
|
||||
pub output_name: String,
|
||||
/// The path of the all the files generated by cargo-leptos
|
||||
#[builder(setter(into), default=".".to_string())]
|
||||
#[builder(setter(into), default="target/site".to_string())]
|
||||
pub site_root: String,
|
||||
/// The path of the WASM and JS files generated by wasm-bindgen from the root of your app
|
||||
/// By default, wasm-bindgen puts them in `pkg`.
|
||||
|
|
Loading…
Reference in a new issue