From 555da6da3d30880839794bbcdd12cf9a283bd797 Mon Sep 17 00:00:00 2001 From: Fangdun Tsai <cfddream@gmail.com> Date: Thu, 19 Oct 2023 06:42:19 +0800 Subject: [PATCH] fix(handlers): get params from route_info --- Cargo.toml | 2 +- viz-handlers/src/embed.rs | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6740c84e..2bdeee71 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -83,7 +83,7 @@ mime_guess = "2.0" percent-encoding = "2.3" hex = "0.4" -rust-embed = "6.8" +rust-embed = "8" # OpenTelemetry opentelemetry = { version = "0.20", default-features = false } diff --git a/viz-handlers/src/embed.rs b/viz-handlers/src/embed.rs index d91c64ae..86191ddd 100644 --- a/viz-handlers/src/embed.rs +++ b/viz-handlers/src/embed.rs @@ -7,8 +7,7 @@ use rust_embed::{EmbeddedFile, RustEmbed}; use viz_core::{ async_trait, header::{HeaderMap, CONTENT_TYPE, ETAG, IF_NONE_MATCH}, - types::Params, - Handler, IntoResponse, Method, Request, Response, Result, StatusCode, + Handler, IntoResponse, Method, Request, RequestExt, Response, Result, StatusCode, }; /// Serve a single embedded file. @@ -65,11 +64,7 @@ where type Output = Result<Response>; async fn call(&self, req: Request) -> Self::Output { - let path = match req - .extensions() - .get::<Params>() - .and_then(|params| params.first().map(|(_, v)| v)) - { + let path = match req.route_info().params.first().map(|(_, v)| v) { Some(p) => p, None => "index.html", };