Skip to content

Commit

Permalink
chore: updated axum version in perseus-axum (#244)
Browse files Browse the repository at this point in the history
* Update axum version for perseus-axum

* Attempt to fix CI

* Fix tests for axum, leading slashes are no longer guaranteed
  • Loading branch information
wingertge committed Dec 1, 2022
1 parent 968595b commit 9e6501a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/perseus-axum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ categories = ["wasm", "web-programming::http-server", "development-tools", "asyn

[dependencies]
perseus = { path = "../perseus", version = "0.4.0-beta.11" }
axum = "0.5"
axum = "0.6"
tower = "0.4"
tower-http = { version = "0.3", features = [ "fs" ] }
urlencoding = "2.1"
Expand Down
4 changes: 1 addition & 3 deletions packages/perseus-axum/src/dflt_server.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use crate::get_router;
use perseus::{
i18n::TranslationsManager, server::ServerProps, stores::MutableStore, PerseusAppBase, SsrNode,
};
use perseus::{i18n::TranslationsManager, server::ServerProps, stores::MutableStore};
use std::net::SocketAddr;

/// Creates and starts the default Perseus server with Axum. This should be run
Expand Down
3 changes: 2 additions & 1 deletion packages/perseus-axum/src/page_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ pub async fn page_handler<M: MutableStore, T: TranslationsManager>(
.collect::<Vec<&str>>()
.join("/");
// Axum's paths have leading slashes
let path = path.strip_prefix('/').unwrap();
// As of 0.6, they do not always have slashes, see #1086 in tokio-rs/axum
let path = path.strip_prefix('/').unwrap_or(&path);

let templates = &opts.templates_map;
// Check if the locale is supported
Expand Down
4 changes: 2 additions & 2 deletions packages/perseus-axum/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub async fn get_router<M: MutableStore + 'static, T: TranslationsManager + 'sta
));
// Only add the static content directory route if such a directory is being used
if let Some(static_dir) = static_dir {
router = router.nest(
router = router.nest_service(
"/.perseus/static",
get_service(ServeDir::new(static_dir)).handle_error(handle_fs_error),
)
Expand All @@ -108,7 +108,7 @@ pub async fn get_router<M: MutableStore + 'static, T: TranslationsManager + 'sta
);
}
// And add the fallback for initial loads
router.fallback(get(closure!(
router.fallback_service(get(closure!(
clone opts,
clone html_shell,
clone render_cfg,
Expand Down

0 comments on commit 9e6501a

Please sign in to comment.