11use std:: net:: SocketAddr ;
22
3+ use axum:: headers:: ContentEncoding ;
34use axum:: http:: { HeaderValue , StatusCode } ;
4- use axum:: response:: { Headers , Html , IntoResponse , Response } ;
5+ use axum:: response:: { Html , IntoResponse , Response } ;
56use axum:: routing:: { get, get_service} ;
6- use axum:: Router ;
7+ use axum:: { Router , TypedHeader } ;
78use tower:: ServiceBuilder ;
89use 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