@@ -29,24 +29,24 @@ pub struct CorsConfig {
2929 /// its value to false).
3030 ///
3131 /// Source: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials
32- allow_credentials : bool ,
32+ pub ( crate ) allow_credentials : bool ,
3333 /// The Access-Control-Allow-Headers response header is used in response to a
3434 /// preflight request which includes the Access-Control-Request-Headers to
3535 /// indicate which HTTP headers can be used during the actual request.
3636 ///
3737 /// Source: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers
38- allow_headers : Option < Vec < String > > ,
38+ pub ( crate ) allow_headers : Option < Vec < String > > ,
3939 /// The Access-Control-Allow-Methods response header specifies the method or
4040 /// methods allowed when accessing the resource in response to a preflight
4141 /// request.
4242 ///
4343 /// Source: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Methods
44- allow_methods : Option < Vec < String > > ,
44+ pub ( crate ) allow_methods : Option < Vec < String > > ,
4545 /// The Access-Control-Allow-Origin response header indicates whether the
4646 /// response can be shared with requesting code from the given origin.
4747 ///
4848 /// Source: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin
49- allow_origin : Option < String > ,
49+ pub ( crate ) allow_origin : Option < String > ,
5050 /// The Access-Control-Expose-Headers response header allows a server to
5151 /// indicate which response headers should be made available to scripts
5252 /// running in the browser, in response to a cross-origin request.
@@ -56,28 +56,28 @@ pub struct CorsConfig {
5656 /// using the Access-Control-Expose-Headers header.
5757 ///
5858 /// Source: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers
59- expose_headers : Option < Vec < String > > ,
59+ pub ( crate ) expose_headers : Option < Vec < String > > ,
6060 /// The Access-Control-Max-Age response header indicates how long the results
6161 /// of a preflight request (that is the information contained in the
6262 /// Access-Control-Allow-Methods and Access-Control-Allow-Headers headers)
6363 /// can be cached.
6464 ///
6565 /// Source: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age
66- max_age : Option < Duration > ,
66+ pub ( crate ) max_age : Option < u64 > ,
6767 /// The Access-Control-Request-Headers request header is used by browsers
6868 /// when issuing a preflight request, to let the server know which HTTP
6969 /// headers the client might send when the actual request is made (such as
7070 /// with setRequestHeader()). This browser side header will be answered by
7171 /// the complementary server side header of Access-Control-Allow-Headers.
7272 ///
7373 /// Source: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Request-Headers
74- request_headers : Option < Vec < String > > ,
74+ pub ( crate ) request_headers : Option < Vec < String > > ,
7575 /// The Access-Control-Request-Method request header is used by browsers when
7676 /// issuing a preflight request, to let the server know which HTTP method will
7777 /// be used when the actual request is made. This header is necessary as the
7878 /// preflight request is always an OPTIONS and doesn't use the same method as
7979 /// the actual request.
80- request_method : Option < String > ,
80+ pub ( crate ) request_method : Option < String > ,
8181}
8282
8383impl CorsConfig {
@@ -104,7 +104,7 @@ impl CorsConfig {
104104 "Content-Type" . to_string( ) ,
105105 ] ) ,
106106 allow_credentials : false ,
107- max_age : Some ( Duration :: from_secs ( 43200 ) ) ,
107+ max_age : Some ( 43200 ) ,
108108 expose_headers : None ,
109109 request_headers : None ,
110110 request_method : None ,
@@ -153,7 +153,7 @@ impl CorsConfigBuilder {
153153 self
154154 }
155155
156- pub fn max_age ( mut self , duration : Duration ) -> Self {
156+ pub fn max_age ( mut self , duration : u64 ) -> Self {
157157 self . config . max_age = Some ( duration) ;
158158 self
159159 }
@@ -188,7 +188,7 @@ pub struct CorsConfigFile {
188188 pub allow_methods : Option < Vec < String > > ,
189189 pub allow_origin : Option < String > ,
190190 pub expose_headers : Option < Vec < String > > ,
191- pub max_age : Option < f64 > ,
191+ pub max_age : Option < u64 > ,
192192 pub request_headers : Option < Vec < String > > ,
193193 pub request_method : Option < String > ,
194194}
@@ -220,7 +220,7 @@ impl TryFrom<CorsConfigFile> for CorsConfig {
220220 }
221221
222222 if let Some ( max_age) = file_config. max_age {
223- cors_config_builder = cors_config_builder. max_age ( Duration :: from_secs_f64 ( max_age) ) ;
223+ cors_config_builder = cors_config_builder. max_age ( max_age) ;
224224 }
225225
226226 if let Some ( request_headers) = file_config. request_headers {
@@ -308,7 +308,7 @@ mod tests {
308308 ] )
309309 ) ;
310310 assert_eq ! ( cors_config. allow_credentials, false ) ;
311- assert_eq ! ( cors_config. max_age, Some ( Duration :: from_secs ( 43200 ) ) ) ;
311+ assert_eq ! ( cors_config. max_age, Some ( 43200 ) ) ;
312312 assert_eq ! ( cors_config. expose_headers, None ) ;
313313 assert_eq ! ( cors_config. request_headers, None ) ;
314314 assert_eq ! ( cors_config. request_method, None ) ;
@@ -324,7 +324,7 @@ mod tests {
324324 let allow_mehtods = vec ! [ "GET" . to_string( ) , "POST" . to_string( ) , "PUT" . to_string( ) ] ;
325325 let allow_origin = String :: from ( "github.com" ) ;
326326 let expose_headers = vec ! [ "content-type" . to_string( ) , "request-id" . to_string( ) ] ;
327- let max_age = 5400. ;
327+ let max_age = 5400 ;
328328 let request_headers = vec ! [
329329 "content-type" . to_string( ) ,
330330 "content-length" . to_string( ) ,
@@ -347,7 +347,7 @@ mod tests {
347347 allow_methods : Some ( allow_mehtods) ,
348348 allow_origin : Some ( allow_origin) ,
349349 expose_headers : Some ( expose_headers) ,
350- max_age : Some ( Duration :: from_secs_f64 ( max_age) ) ,
350+ max_age : Some ( max_age) ,
351351 request_headers : Some ( request_headers) ,
352352 request_method : Some ( request_method) ,
353353 } ;
0 commit comments