@@ -65,17 +65,29 @@ impl Service<Request<Body>> for Svc {
65
65
66
66
#[ cfg( not( feature = "__ci" ) ) ]
67
67
fn call ( & mut self , req : Request < Body > ) -> Self :: Future {
68
- let rsp = Response :: builder ( ) ;
69
-
70
- let bytes = match req. uri ( ) . path ( ) {
71
- "/" | "/index.html" => & include_bytes ! ( "../web_viewer/index.html" ) [ ..] ,
72
- "/favicon.ico" => & include_bytes ! ( "../web_viewer/favicon.ico" ) [ ..] ,
73
- "/sw.js" => & include_bytes ! ( "../web_viewer/sw.js" ) [ ..] ,
68
+ let response = Response :: builder ( ) ;
69
+
70
+ let ( mime, bytes) = match req. uri ( ) . path ( ) {
71
+ "/" | "/index.html" => ( "text/html" , & include_bytes ! ( "../web_viewer/index.html" ) [ ..] ) ,
72
+ "/favicon.ico" => (
73
+ "image/vnd.microsoft.icon" ,
74
+ & include_bytes ! ( "../web_viewer/favicon.ico" ) [ ..] ,
75
+ ) ,
76
+ "/sw.js" => (
77
+ "text/javascript" ,
78
+ & include_bytes ! ( "../web_viewer/sw.js" ) [ ..] ,
79
+ ) ,
74
80
75
81
#[ cfg( debug_assertions) ]
76
- "/re_viewer.js" => & include_bytes ! ( "../web_viewer/re_viewer_debug.js" ) [ ..] ,
82
+ "/re_viewer.js" => (
83
+ "text/javascript" ,
84
+ & include_bytes ! ( "../web_viewer/re_viewer_debug.js" ) [ ..] ,
85
+ ) ,
77
86
#[ cfg( not( debug_assertions) ) ]
78
- "/re_viewer.js" => & include_bytes ! ( "../web_viewer/re_viewer.js" ) [ ..] ,
87
+ "/re_viewer.js" => (
88
+ "text/javascript" ,
89
+ & include_bytes ! ( "../web_viewer/re_viewer.js" ) [ ..] ,
90
+ ) ,
79
91
80
92
"/re_viewer_bg.wasm" => {
81
93
#[ cfg( feature = "analytics" ) ]
@@ -84,24 +96,34 @@ impl Service<Request<Body>> for Svc {
84
96
#[ cfg( debug_assertions) ]
85
97
{
86
98
re_log:: info_once!( "Serving DEBUG web-viewer" ) ;
87
- & include_bytes ! ( "../web_viewer/re_viewer_debug_bg.wasm" ) [ ..]
99
+ (
100
+ "application/wasm" ,
101
+ & include_bytes ! ( "../web_viewer/re_viewer_debug_bg.wasm" ) [ ..] ,
102
+ )
88
103
}
89
104
#[ cfg( not( debug_assertions) ) ]
90
105
{
91
- & include_bytes ! ( "../web_viewer/re_viewer_bg.wasm" ) [ ..]
106
+ (
107
+ "application/wasm" ,
108
+ & include_bytes ! ( "../web_viewer/re_viewer_bg.wasm" ) [ ..] ,
109
+ )
92
110
}
93
111
}
94
112
_ => {
95
113
re_log:: warn!( "404 path: {}" , req. uri( ) . path( ) ) ;
96
114
let body = Body :: from ( Vec :: new ( ) ) ;
97
- let rsp = rsp . status ( 404 ) . body ( body) . unwrap ( ) ;
115
+ let rsp = response . status ( 404 ) . body ( body) . unwrap ( ) ;
98
116
return future:: ok ( rsp) ;
99
117
}
100
118
} ;
101
119
102
120
let body = Body :: from ( Vec :: from ( bytes) ) ;
103
- let rsp = rsp. status ( 200 ) . body ( body) . unwrap ( ) ;
104
- future:: ok ( rsp)
121
+ let mut response = response. status ( 200 ) . body ( body) . unwrap ( ) ;
122
+ response. headers_mut ( ) . insert (
123
+ hyper:: header:: CONTENT_TYPE ,
124
+ hyper:: header:: HeaderValue :: from_static ( mime) ,
125
+ ) ;
126
+ future:: ok ( response)
105
127
}
106
128
}
107
129
0 commit comments