Skip to content

Commit

Permalink
remove hyper dependency on dashboard proxy
Browse files Browse the repository at this point in the history
Signed-off-by: Bugen Zhao <[email protected]>
  • Loading branch information
BugenZhao committed Apr 4, 2024
1 parent 500fdb0 commit f69fd95
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/meta/dashboard/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ anyhow = "1"
axum = { workspace = true }
axum-embed = "0.1"
bytes = "1"
hyper = "1"
mime_guess = "2"
reqwest = "0.12.2"
rust-embed = { version = "8", features = ["interpolate-folder-path", "mime-guess"] }
Expand Down
20 changes: 9 additions & 11 deletions src/meta/dashboard/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ use std::collections::HashMap;
use std::sync::{Arc, Mutex};

use anyhow::anyhow;
use axum::http::StatusCode;
use axum::http::{header, HeaderMap, StatusCode, Uri};
use axum::response::{IntoResponse, Response};
use axum::Router;
use bytes::Bytes;
use hyper::header::CONTENT_TYPE;
use hyper::{HeaderMap, Uri};
use thiserror_ext::AsReport as _;
use url::Url;

Expand All @@ -37,21 +35,21 @@ impl IntoResponse for CachedResponse {
fn into_response(self) -> Response {
let guess = mime_guess::from_path(self.uri.path());
let mut headers = HeaderMap::new();
if let Some(x) = self.headers.get(hyper::header::ETAG) {
headers.insert(hyper::header::ETAG, x.clone());
if let Some(x) = self.headers.get(header::ETAG) {
headers.insert(header::ETAG, x.clone());
}
if let Some(x) = self.headers.get(hyper::header::CACHE_CONTROL) {
headers.insert(hyper::header::CACHE_CONTROL, x.clone());
if let Some(x) = self.headers.get(header::CACHE_CONTROL) {
headers.insert(header::CACHE_CONTROL, x.clone());
}
if let Some(x) = self.headers.get(hyper::header::EXPIRES) {
headers.insert(hyper::header::EXPIRES, x.clone());
if let Some(x) = self.headers.get(header::EXPIRES) {
headers.insert(header::EXPIRES, x.clone());
}
if let Some(x) = guess.first() {
if x.type_() == "image" && x.subtype() == "svg" {
headers.insert(CONTENT_TYPE, "image/svg+xml".parse().unwrap());
headers.insert(header::CONTENT_TYPE, "image/svg+xml".parse().unwrap());
} else {
headers.insert(
CONTENT_TYPE,
header::CONTENT_TYPE,
format!("{}/{}", x.type_(), x.subtype()).parse().unwrap(),
);
}
Expand Down

0 comments on commit f69fd95

Please sign in to comment.