-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: support axum permanent redirect * feat: lowercase route names * feat: allow redirection on client side routing * doc: update tutorial * refactor: update useListenBrowserUrlUpdates hook * refactor: moved initRouterStore to useRouterStore file * feat: update version to v0.3.0 * fix: types
- Loading branch information
1 parent
7401a59
commit b6d0bb1
Showing
16 changed files
with
219 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "tuono" | ||
version = "0.2.5" | ||
version = "0.3.0" | ||
edition = "2021" | ||
authors = ["V. Ageno <[email protected]>"] | ||
description = "The react/rust fullstack framework" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "tuono_lib" | ||
version = "0.2.5" | ||
version = "0.3.0" | ||
edition = "2021" | ||
authors = ["V. Ageno <[email protected]>"] | ||
description = "The react/rust fullstack framework" | ||
|
@@ -24,8 +24,9 @@ serde = { version = "1.0.202", features = ["derive"] } | |
erased-serde = "0.4.5" | ||
serde_json = "1.0" | ||
|
||
tuono_lib_macros = {path = "../tuono_lib_macros", version = "0.2.5"} | ||
tuono_lib_macros = {path = "../tuono_lib_macros", version = "0.3.0"} | ||
once_cell = "1.19.0" | ||
lazy_static = "1.5.0" | ||
regex = "1.10.5" | ||
either = "1.13.0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// src/routes/pokemons/GOAT.rs | ||
use tuono_lib::{Request, Response}; | ||
|
||
#[tuono_lib::handler] | ||
async fn redirect_to_goat(_: Request<'_>, _: reqwest::Client) -> Response { | ||
Response::Redirect("/pokemons/mewtwo".to_string()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/tuono/src/router/hooks/useListenBrowserUrlUpdates.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { useRouterStore } from './useRouterStore' | ||
import { useEffect } from 'react' | ||
|
||
/* | ||
* This hook is meant to handle just browser related location updates | ||
* like the back and forward buttons. | ||
*/ | ||
export const useListenBrowserUrlUpdates = (): void => { | ||
const updateLocation = useRouterStore((st) => st.updateLocation) | ||
|
||
const updateLocationOnPopStateChange = ({ target }: any): void => { | ||
const { pathname, hash, href, search } = target.location | ||
updateLocation({ | ||
pathname, | ||
hash, | ||
href, | ||
searchStr: search, | ||
search: new URLSearchParams(search), | ||
}) | ||
} | ||
useEffect(() => { | ||
window.addEventListener('popstate', updateLocationOnPopStateChange) | ||
return (): void => { | ||
window.removeEventListener('popstate', updateLocationOnPopStateChange) | ||
} | ||
}, []) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.