update functions for Windows file directories

- leptos_macro/src/server.rs server_macro_impl
 - integrations/axum/src/lib.rs handle_server_fns
This commit is contained in:
indrazar 2022-11-30 22:57:16 -05:00
parent 8d671866a3
commit 8ec772a129
2 changed files with 8 additions and 1 deletions

View File

@ -46,7 +46,11 @@ pub async fn handle_server_fns(
// req: Request<Body>,
) -> impl IntoResponse {
// Axum Path extractor doesn't remove the first slash from the path, while Actix does
let fn_name = fn_name.replace("/", "");
let fn_name: String = match fn_name.strip_prefix("/") {
Some(path) => path.to_string(),
None => fn_name,
};
println!("landed at handle_server_fns, looking for {fn_name}");
println!("Body: {:#?}", &body);
let (tx, rx) = futures::channel::oneshot::channel();

View File

@ -46,7 +46,10 @@ pub fn server_macro_impl(args: proc_macro::TokenStream, s: TokenStream2) -> Resu
if #[cfg(not(feature = "stable"))] {
use proc_macro::Span;
let span = Span::call_site();
#[cfg(not(target_os = "windows"))]
let url = format!("{}/{}", span.source_file().path().to_string_lossy(), fn_name_as_str).replace("/", "-");
#[cfg(target_os = "windows")]
let url = format!("{}/{}", span.source_file().path().to_string_lossy(), fn_name_as_str).replace("\\", "-");
} else {
let url = fn_name_as_str;
}