Skip to content

Commit

Permalink
Bump tower to v0.5 (#4075)
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored Aug 17, 2024
1 parent b012a75 commit e5c6386
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion crates/example-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tokio = { version = "1.29.1", features = ["macros", "net", "time"] }
tokio-tungstenite = "0.23"
tower = { version = "0.4.13", features = ["make"] }
tower = { version = "0.5", features = ["make", "util"] }
tower-http = { version = "0.5", features = ["fs", "util", "set-header"] }
23 changes: 13 additions & 10 deletions crates/example-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{env, str};

use anyhow::{bail, Context};
use futures_util::{future, SinkExt, StreamExt};
use http::{HeaderName, HeaderValue};
use http::{HeaderName, HeaderValue, Response};
use hyper_util::rt::{TokioExecutor, TokioIo};
use hyper_util::server::conn::auto::Builder;
use hyper_util::service::TowerToHyperService;
Expand All @@ -24,8 +24,8 @@ use tokio::time::timeout;
use tokio_tungstenite::tungstenite::{self, Message};
use tokio_tungstenite::{MaybeTlsStream, WebSocketStream};
use tower::ServiceBuilder;
use tower_http::services::fs::ServeFileSystemResponseBody;
use tower_http::services::ServeDir;
use tower_http::ServiceBuilderExt;

/// A command sent from the client to the server.
#[derive(Serialize)]
Expand Down Expand Up @@ -330,14 +330,17 @@ pub async fn test_example(
// Serve the path.
let service = TowerToHyperService::new(
ServiceBuilder::new()
.override_response_header(
HeaderName::from_static("cross-origin-opener-policy"),
HeaderValue::from_static("same-origin"),
)
.override_response_header(
HeaderName::from_static("cross-origin-embedder-policy"),
HeaderValue::from_static("require-corp"),
)
.map_response(|mut response: Response<ServeFileSystemResponseBody>| {
response.headers_mut().insert(
HeaderName::from_static("cross-origin-opener-policy"),
HeaderValue::from_static("same-origin"),
);
response.headers_mut().insert(
HeaderName::from_static("cross-origin-embedder-policy"),
HeaderValue::from_static("require-corp"),
);
response
})
.service(ServeDir::new(path)),
);

Expand Down

0 comments on commit e5c6386

Please sign in to comment.