add tower live reload to auto refresh page on save

This commit is contained in:
Triston Armstrong 2024-03-26 16:58:47 -05:00
parent b26edbe0d1
commit 3a14b62c07
3 changed files with 19 additions and 1 deletions

15
Cargo.lock generated
View File

@ -1172,6 +1172,7 @@ dependencies = [
"sqlx", "sqlx",
"tokio", "tokio",
"tokio-stream", "tokio-stream",
"tower-livereload",
] ]
[[package]] [[package]]
@ -3109,6 +3110,20 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0"
[[package]]
name = "tower-livereload"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61d6cbbab4b2d3cafd21fb211cc4b06525a0df919c3e8ca3d36485b1c1bd4cd4"
dependencies = [
"bytes",
"http 1.1.0",
"http-body 1.0.0",
"pin-project-lite",
"tokio",
"tower",
]
[[package]] [[package]]
name = "tower-service" name = "tower-service"
version = "0.3.2" version = "0.3.2"

View File

@ -16,3 +16,4 @@ shuttle-shared-db = { version = "0.42.0", features = ["postgres", "sqlx"] }
sqlx = { version = "0.7.2", features = ["runtime-tokio-rustls", "postgres"] } sqlx = { version = "0.7.2", features = ["runtime-tokio-rustls", "postgres"] }
tokio = "1.28.2" tokio = "1.28.2"
tokio-stream = { version = "0.1.14", features = ["sync"] } tokio-stream = { version = "0.1.14", features = ["sync"] }
tower-livereload = "0.9.2"

View File

@ -54,5 +54,7 @@ pub fn init_router() -> Router {
.nest("/notes", init_notes_routes()) .nest("/notes", init_notes_routes())
.nest("/", init_utily_routes()); .nest("/", init_utily_routes());
Router::new().nest("/", routes) Router::new()
.nest("/", routes)
.layer(tower_livereload::LiveReloadLayer::new())
} }