@@ -10,10 +10,7 @@ use http::uri::Authority;
1010use http_body_util:: combinators:: BoxBody ;
1111use http_body_util:: { BodyExt , Empty , Full } ;
1212use hyper:: body:: { Bytes , Incoming } ;
13- use hyper:: header:: {
14- HeaderValue , ACCESS_CONTROL_ALLOW_HEADERS , ACCESS_CONTROL_ALLOW_METHODS ,
15- ACCESS_CONTROL_ALLOW_ORIGIN , CONTENT_LENGTH , CONTENT_TYPE ,
16- } ;
13+ use hyper:: header:: { HeaderValue , CONTENT_LENGTH , CONTENT_TYPE } ;
1714use hyper:: { Method , Request , Response } ;
1815use hyper_rustls:: builderstates:: WantsSchemes ;
1916use hyper_rustls:: { HttpsConnector , HttpsConnectorBuilder } ;
@@ -160,8 +157,7 @@ where
160157 let path = req. uri ( ) . path ( ) ;
161158 let authority = req. uri ( ) . authority ( ) . cloned ( ) ;
162159
163- let mut res = match ( & method, path) {
164- ( & Method :: OPTIONS , _) => Ok ( handle_preflight ( ) ) ,
160+ let res = match ( & method, path) {
165161 ( & Method :: GET , "/health" ) => Ok ( health_check ( ) . await ) ,
166162 ( & Method :: POST , _) => match parse_gateway_uri ( & method, path, authority, config) . await {
167163 Ok ( gateway_uri) => handle_ohttp_relay ( req, config, gateway_uri) . await ,
@@ -178,7 +174,6 @@ where
178174 _ => Err ( Error :: NotFound ) ,
179175 }
180176 . unwrap_or_else ( |e| e. to_response ( ) ) ;
181- res. headers_mut ( ) . insert ( ACCESS_CONTROL_ALLOW_ORIGIN , HeaderValue :: from_static ( "*" ) ) ;
182177 Ok ( res)
183178}
184179
@@ -227,21 +222,6 @@ fn parse_gateway_uri_from_path(path: &str, default: &GatewayUri) -> Result<Gatew
227222 }
228223}
229224
230- fn handle_preflight ( ) -> Response < BoxBody < Bytes , hyper:: Error > > {
231- let mut res = Response :: new ( empty ( ) ) ;
232- * res. status_mut ( ) = hyper:: StatusCode :: NO_CONTENT ;
233- res. headers_mut ( ) . insert ( ACCESS_CONTROL_ALLOW_ORIGIN , HeaderValue :: from_static ( "*" ) ) ;
234- res. headers_mut ( ) . insert (
235- ACCESS_CONTROL_ALLOW_METHODS ,
236- HeaderValue :: from_static ( "CONNECT, GET, OPTIONS, POST" ) ,
237- ) ;
238- res. headers_mut ( ) . insert (
239- ACCESS_CONTROL_ALLOW_HEADERS ,
240- HeaderValue :: from_static ( "Content-Type, Content-Length" ) ,
241- ) ;
242- res
243- }
244-
245225async fn health_check ( ) -> Response < BoxBody < Bytes , hyper:: Error > > { Response :: new ( empty ( ) ) }
246226
247227#[ instrument]
0 commit comments