Skip to content

Commit bf2999e

Browse files
update dependencies
1 parent 040ed0a commit bf2999e

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
1616

1717
wasm-bindgen-cli-support = "0.2"
1818

19-
axum = { version = "0.4", default-features = false, features = ["http1"] }
19+
axum = { version = "0.5", default-features = false, features = ["http1", "headers"] }
2020
tokio = { version = "1.11", default-features = false, features = ["rt-multi-thread"] }
2121
tower-http = { version = "0.2", features = ["fs", "trace"] }
2222
tower = "0.4"

src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ fn main() -> Result<(), anyhow::Error> {
1717
tracing_subscriber::fmt::fmt().without_time().with_env_filter(filter).init();
1818

1919
let title = std::env::var("CARGO_PKG_NAME").unwrap_or_else(|_| "".to_string());
20-
let address = std::env::var("WASM_SERVER_RUNNER_ADDRESS").unwrap_or_else(|_| "127.0.0.1".to_string());
20+
let address =
21+
std::env::var("WASM_SERVER_RUNNER_ADDRESS").unwrap_or_else(|_| "127.0.0.1".to_string());
2122

2223
let options = Options { title, address };
2324

src/server.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
use std::net::SocketAddr;
22

3+
use axum::headers::ContentEncoding;
34
use axum::http::{HeaderValue, StatusCode};
4-
use axum::response::{Headers, Html, IntoResponse, Response};
5+
use axum::response::{Html, IntoResponse, Response};
56
use axum::routing::{get, get_service};
6-
use axum::Router;
7+
use axum::{Router, TypedHeader};
78
use tower::ServiceBuilder;
89
use tower_http::services::ServeDir;
910

@@ -31,9 +32,7 @@ pub async fn run_server(options: Options, output: WasmBindgenOutput) -> Result<(
3132
let serve_dir = get_service(ServeDir::new(".")).handle_error(internal_server_error);
3233

3334
let serve_wasm = || async move {
34-
let headers = Headers(std::iter::once(("Content-Encoding", "gzip")));
35-
let response = WithContentType("application/wasm", compressed_wasm);
36-
(headers, response)
35+
(TypedHeader(ContentEncoding::gzip()), WithContentType("application/wasm", compressed_wasm))
3736
};
3837

3938
let app = Router::new()
@@ -46,7 +45,8 @@ pub async fn run_server(options: Options, output: WasmBindgenOutput) -> Result<(
4645

4746
let mut address_string = options.address;
4847
if !address_string.contains(":") {
49-
address_string += &(":".to_owned() + &pick_port::pick_free_port(1334, 10).unwrap_or(1334).to_string());
48+
address_string +=
49+
&(":".to_owned() + &pick_port::pick_free_port(1334, 10).unwrap_or(1334).to_string());
5050
}
5151
let addr: SocketAddr = address_string.parse().expect("Couldn't parse address");
5252

0 commit comments

Comments
 (0)