-
Looking at the examples for Router::new().get("/w/*", static_file_handler).get(
"/",
Box::new(|conn: trillium::Conn| async move {
conn.with_header("location", "/w/").with_status(302).halt()
}),
) My want to do that is to allow for complete URLs to be passed to the browser and for a fallback page for sorts to catch that and handle the client-side routing correctly (namely Svelte, in this case). The hope is that I can give it a specific path to |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
What I've done in the interim is have a special query parameter that my CSR app can detect and do the client side redirection for. In the CSR app: onMount(() => {
let goPath = $page.query.get('go') || (new URLSearchParams(location.search)).get('go');
if (goPath) {
goto(`/w/${goPath}`);
}
}); And in my app code: conn.with_status(Status::PermanentRedirect)
.with_header("Location", format!("/w/?go=requests/{}", request.id))
.halt() |
Beta Was this translation helpful? Give feedback.
-
I'm not certain I understand what you're looking for, but there are two ways to make a fall-through router match. One is to mount a handler at If instead, the need is to be able to always serve a specific file from the static file handler, there are changes I can release today that always serve a specific file regardless of path if instead of calling StaticFileHandler::new with a path to a directory, you call it with a single file |
Beta Was this translation helpful? Give feedback.
I'm not certain I understand what you're looking for, but there are two ways to make a fall-through router match. One is to mount a handler at
"*"
, and the other is to do(Router::new().get(…), StaticCompiledHandler::new(…))
— the router will only halt the conn if it matches a route, so any unmatched route will continue onto the next handler. In routefinder, there's no distinction between "**
" and"*"
in that"*"
matches anything including slashes, all the way to the end of the pathIf instead, the need is to be able to always serve a specific file from the static file handler, there are changes I can release today that always serve a specific file regardless of path if instead of calling…