fixup! Very simple CORS implementation

This commit is contained in:
Artem Biryukov 2017-01-19 04:26:29 +03:00
parent 9d7ad109cd
commit cb713c478d
No known key found for this signature in database
GPG Key ID: AC9644A627DDAA9D
4 changed files with 6 additions and 2 deletions

View File

@ -12,6 +12,7 @@ license = "MIT/Apache-2.0"
[features] [features]
default = ["json"] default = ["json"]
cors = []
json = ["serde", "serde_json"] json = ["serde", "serde_json"]
tera_templates = ["tera", "templates"] tera_templates = ["tera", "templates"]
handlebars_templates = ["handlebars", "templates"] handlebars_templates = ["handlebars", "templates"]

View File

@ -40,6 +40,7 @@
#[cfg(feature = "lazy_static_macro")] #[cfg(feature = "lazy_static_macro")]
extern crate lazy_static; extern crate lazy_static;
#[cfg(feature = "cors")]
mod cors; mod cors;
#[cfg_attr(feature = "json", macro_use)] #[cfg_attr(feature = "json", macro_use)]
@ -52,6 +53,7 @@ mod templates;
#[cfg(feature = "uuid")] #[cfg(feature = "uuid")]
mod uuid; mod uuid;
#[cfg(feature = "cors")]
pub use cors::{PreflightCORS, CORS}; pub use cors::{PreflightCORS, CORS};
#[cfg(feature = "json")] #[cfg(feature = "json")]

View File

@ -9,8 +9,9 @@ rocket = { path = "../../lib" }
rocket_codegen = { path = "../../codegen" } rocket_codegen = { path = "../../codegen" }
[dependencies.rocket_contrib] [dependencies.rocket_contrib]
default-features = true default-features = false
path = "../../contrib" path = "../../contrib"
features = ["cors"]
[dev-dependencies] [dev-dependencies]
rocket = { path = "../../lib", features = ["testing"] } rocket = { path = "../../lib", features = ["testing"] }

View File

@ -17,6 +17,6 @@ fn hello() -> CORS<String> {
fn main() { fn main() {
rocket::ignite() rocket::ignite()
.mount("/", routes![cors_preflight, hello]) .mount("/", routes![hello])
.launch(); .launch();
} }