From 156807acd0c9333766759905d82d17babad89b14 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Thu, 19 Sep 2024 13:54:09 +0200 Subject: [PATCH] feat(examples): bump picoserve to 0.12.x --- Cargo.lock | 17 ++++++++++++++--- examples/embassy-http-server/Cargo.toml | 2 +- examples/embassy-http-server/src/main.rs | 10 ++++++++-- .../embassy-http-server/src/routes/index.rs | 8 -------- examples/embassy-http-server/src/routes/mod.rs | 4 ---- 5 files changed, 23 insertions(+), 18 deletions(-) delete mode 100644 examples/embassy-http-server/src/routes/index.rs diff --git a/Cargo.lock b/Cargo.lock index d68143696..00b2f0850 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3283,9 +3283,9 @@ dependencies = [ [[package]] name = "picoserve" -version = "0.8.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "912e6e8713f815d30bb77fa052cc8036a2b6429dc436969311fad47705fe0f2a" +checksum = "289ba0d65f123eb9c55ee8e34c0227f3c17b4298bb47ef05cbd0caa0e6a06d49" dependencies = [ "const-sha1", "data-encoding", @@ -3295,9 +3295,9 @@ dependencies = [ "futures-util", "heapless 0.8.0", "lhash", - "log 0.4.22", "ryu", "serde", + "serde-json-core", ] [[package]] @@ -4040,6 +4040,17 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-json-core" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b81787e655bd59cecadc91f7b6b8651330b2be6c33246039a65e5cd6f4e0828" +dependencies = [ + "heapless 0.8.0", + "ryu", + "serde", +] + [[package]] name = "serde_cbor" version = "0.11.2" diff --git a/examples/embassy-http-server/Cargo.toml b/examples/embassy-http-server/Cargo.toml index ee176da29..ac32790c0 100644 --- a/examples/embassy-http-server/Cargo.toml +++ b/examples/embassy-http-server/Cargo.toml @@ -17,7 +17,7 @@ embassy-time = { workspace = true, default-features = false } embedded-io-async = { version = "0.6.0", features = ["defmt-03"] } heapless = { workspace = true } httparse = { version = "1.8.0", default-features = false } -picoserve = { version = "0.8.0", default-features = false, features = [ +picoserve = { version = "0.12.0", default-features = false, features = [ "embassy", ] } riot-rs = { path = "../../src/riot-rs", features = ["override-network-config"] } diff --git a/examples/embassy-http-server/src/main.rs b/examples/embassy-http-server/src/main.rs index 42165c997..f4f4a21f0 100644 --- a/examples/embassy-http-server/src/main.rs +++ b/examples/embassy-http-server/src/main.rs @@ -39,7 +39,7 @@ impl picoserve::extract::FromRef for ButtonInputs { } mod approuter { - use picoserve::routing::get; + use picoserve::routing::{get, get_service}; use crate::routes; @@ -51,7 +51,13 @@ mod approuter { pub type AppRouter = impl picoserve::routing::PathRouter; pub fn make_app() -> picoserve::Router { - let router = picoserve::Router::new().route("/", get(routes::index)); + let router = picoserve::Router::new().route( + "/", + get_service(picoserve::response::File::html(include_str!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/static/index.html", + )))), + ); #[cfg(feature = "button-readings")] let router = router.route("/buttons", get(routes::buttons)); router diff --git a/examples/embassy-http-server/src/routes/index.rs b/examples/embassy-http-server/src/routes/index.rs deleted file mode 100644 index 78b2b538a..000000000 --- a/examples/embassy-http-server/src/routes/index.rs +++ /dev/null @@ -1,8 +0,0 @@ -use picoserve::response::IntoResponse; - -pub async fn index() -> impl IntoResponse { - picoserve::response::File::html(include_str!(concat!( - env!("CARGO_MANIFEST_DIR"), - "/static/index.html", - ))) -} diff --git a/examples/embassy-http-server/src/routes/mod.rs b/examples/embassy-http-server/src/routes/mod.rs index 3126e9f92..1d6f95fe7 100644 --- a/examples/embassy-http-server/src/routes/mod.rs +++ b/examples/embassy-http-server/src/routes/mod.rs @@ -1,9 +1,5 @@ -pub mod index; - #[cfg(feature = "button-readings")] pub mod buttons; -pub use index::index; - #[cfg(feature = "button-readings")] pub use buttons::buttons;