1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! CORS middleware for hyper 1.x.
//!
//! [`Cors`] is a [`hyper::service::Service`] that wraps an inner service and applies the
//! [Cross-Origin Resource Sharing][mdn] protocol to every request.
//!
//! Preflight requests (`OPTIONS` with `Access-Control-Request-Method`) are short-circuited
//! by default, so the inner service never sees them.
//!
//! # Example
//!
//! ```
//! use std::{convert::Infallible, time::Duration};
//! use http::Method;
//! use hyper::{Request, Response, service::Service, body::Incoming};
//! use http_body_util::Full;
//! use bytes::Bytes;
//! use hyper_cors::{Any, Cors};
//!
//! async fn handle(_req: Request<Incoming>) -> Result<Response<Full<Bytes>>, Infallible> {
//! Ok(Response::new(Full::new(Bytes::from("ok"))))
//! }
//!
//! # async fn run() {
//! let svc = hyper_cors::builder()
//! .allow_origin(Any)
//! .allow_methods([Method::GET, Method::POST])
//! .max_age(Duration::from_secs(600))
//! .build(handle);
//! # }
//! ```
//!
//! [mdn]: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
pub use AllowCredentials;
pub use AllowHeaders;
pub use AllowMethods;
pub use ;
pub use ;
pub use ;
pub use ExposeHeaders;
pub use MaxAge;
pub use Vary;