@@ -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 } ;
@@ -182,8 +179,7 @@ where
182179 let path = req. uri ( ) . path ( ) ;
183180 let authority = req. uri ( ) . authority ( ) . cloned ( ) ;
184181
185- let mut res = match ( & method, path) {
186- ( & Method :: OPTIONS , _) => Ok ( handle_preflight ( ) ) ,
182+ let res = match ( & method, path) {
187183 ( & Method :: GET , "/health" ) => Ok ( health_check ( ) . await ) ,
188184 ( & Method :: POST , _) => match parse_gateway_uri ( & method, path, authority, config) . await {
189185 Ok ( gateway_uri) => handle_ohttp_relay ( req, config, gateway_uri) . await ,
@@ -206,7 +202,6 @@ where
206202 _ => Err ( Error :: NotFound ) ,
207203 }
208204 . unwrap_or_else ( |e| e. to_response ( ) ) ;
209- res. headers_mut ( ) . insert ( ACCESS_CONTROL_ALLOW_ORIGIN , HeaderValue :: from_static ( "*" ) ) ;
210205 Ok ( res)
211206}
212207
@@ -255,21 +250,6 @@ fn parse_gateway_uri_from_path(path: &str, default: &GatewayUri) -> Result<Gatew
255250 }
256251}
257252
258- fn handle_preflight ( ) -> Response < BoxBody < Bytes , hyper:: Error > > {
259- let mut res = Response :: new ( empty ( ) ) ;
260- * res. status_mut ( ) = hyper:: StatusCode :: NO_CONTENT ;
261- res. headers_mut ( ) . insert ( ACCESS_CONTROL_ALLOW_ORIGIN , HeaderValue :: from_static ( "*" ) ) ;
262- res. headers_mut ( ) . insert (
263- ACCESS_CONTROL_ALLOW_METHODS ,
264- HeaderValue :: from_static ( "CONNECT, GET, OPTIONS, POST" ) ,
265- ) ;
266- res. headers_mut ( ) . insert (
267- ACCESS_CONTROL_ALLOW_HEADERS ,
268- HeaderValue :: from_static ( "Content-Type, Content-Length" ) ,
269- ) ;
270- res
271- }
272-
273253async fn health_check ( ) -> Response < BoxBody < Bytes , hyper:: Error > > { Response :: new ( empty ( ) ) }
274254
275255#[ instrument]
0 commit comments