fix: invalid borrowing of assets_path in get_router
This commit is contained in:
parent
ca2a0ace71
commit
262b450c75
@ -1,4 +1,4 @@
|
|||||||
use std::path::Path;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use axum::http::{StatusCode, Uri};
|
use axum::http::{StatusCode, Uri};
|
||||||
use axum_htmx::AutoVaryLayer;
|
use axum_htmx::AutoVaryLayer;
|
||||||
@ -11,7 +11,7 @@ async fn fallback(uri: Uri) -> (StatusCode, String) {
|
|||||||
(StatusCode::NOT_FOUND, format!("No route for {uri}"))
|
(StatusCode::NOT_FOUND, format!("No route for {uri}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_router(assets_path: &Path) -> axum::Router {
|
pub async fn get_router(assets_path: PathBuf) -> axum::Router<()> {
|
||||||
axum::Router::new()
|
axum::Router::new()
|
||||||
.nest_service("/assets", ServeDir::new(assets_path))
|
.nest_service("/assets", ServeDir::new(assets_path))
|
||||||
.merge(pages::get_routes())
|
.merge(pages::get_routes())
|
||||||
|
@ -72,7 +72,7 @@ async fn main() -> Result<(), AppError> {
|
|||||||
|
|
||||||
let livereload_layer =
|
let livereload_layer =
|
||||||
get_livereload_layer(templates_paths).map_err(AppError::NotifyWatcher)?;
|
get_livereload_layer(templates_paths).map_err(AppError::NotifyWatcher)?;
|
||||||
let router = get_router(assets_path.as_path()).layer(livereload_layer);
|
let router = get_router(assets_path).await.layer(livereload_layer);
|
||||||
|
|
||||||
let listener: TcpListener = get_tcp_listener().await.map_err(AppError::TCPListener)?;
|
let listener: TcpListener = get_tcp_listener().await.map_err(AppError::TCPListener)?;
|
||||||
let local_addr = listener.local_addr().map_err(AppError::TCPListener)?;
|
let local_addr = listener.local_addr().map_err(AppError::TCPListener)?;
|
||||||
|
@ -55,7 +55,7 @@ pub fn run() {
|
|||||||
|
|
||||||
// Adds Axum router to application state
|
// Adds Axum router to application state
|
||||||
// This makes it so we can retrieve it from any app instance (see bellow)
|
// This makes it so we can retrieve it from any app instance (see bellow)
|
||||||
let router = Arc::new(Mutex::new(app::get_router(&assets_path)));
|
let router = Arc::new(Mutex::new(app::get_router(assets_path)));
|
||||||
|
|
||||||
app.manage(router);
|
app.manage(router);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user