mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-14 00:27:12 +00:00
One more time!
This commit is contained in:
parent
6603c44ce2
commit
01e024b726
3 changed files with 2 additions and 10 deletions
|
@ -9,16 +9,12 @@ if #[cfg(feature = "ssr")] {
|
|||
};
|
||||
use tower::ServiceExt;
|
||||
use tower_http::services::ServeDir;
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
use leptos::LeptosOptions;
|
||||
|
||||
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 root = options.site_root.clone();
|
||||
let res = get_static_file(uri.clone(), &root).await?;
|
||||
|
||||
|
|
|
@ -9,16 +9,12 @@ if #[cfg(feature = "ssr")] {
|
|||
};
|
||||
use tower::ServiceExt;
|
||||
use tower_http::services::ServeDir;
|
||||
use std::str::FromStr;
|
||||
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 root = options.site_root.clone();
|
||||
let res = get_static_file(uri.clone(), &root).await?;
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ if #[cfg(feature = "ssr")] {
|
|||
let app = Router::new()
|
||||
.route("/api/*fn_name", post(leptos_axum::handle_server_fns))
|
||||
.leptos_routes(leptos_options.clone(), routes, |cx| view! { cx, <TodoApp/> } )
|
||||
.route("/*file_path", get(file_handler))
|
||||
.fallback(file_handler)
|
||||
.layer(Extension(Arc::new(leptos_options)));
|
||||
|
||||
// run our app with hyper
|
||||
|
|
Loading…
Reference in a new issue