2.7 KiB
2.7 KiB
CHANGELOG
0.5.2 (2020-03-18)
Improvements
- Add a builder methods for
CorsOptions
(#75)
0.5.1 (2019-11-13)
There are no new features.
- Fix build issues with Rocket 0.4.2
- Fix clippy lints with latest nightly
0.5.0 (2019-05-27)
There is no change since 0.5.0-beta1
.
Breaking Changes
- The
Cors
struct can no longer be constructed. Instead, you will now construct the options for Cors directly or through deserialization using theCorsOptions
struct. Then, you can constructCors
for use in Fairings or manual responses using theCorsOptions::to_cors
method. - The
AllowedOrigins
type has been modified. It is now a typedef ofAllOrSome<Origins>
whereOrigins
is now a struct supporting exact matches or regex matches.
Migrating existing Code
-
Existing use of
AllowedOrigins::some
to create exact matches can be replaced simply withAllowedOrigins::some_exact
instead. -
Replace all construction of
Cors
struct withCorsOptions
instead. Then, you can create theCors
struct for use in Fairings using theCorsOptions::to_cors
method-fn main() { +fn main() -> Result<(), Error> { let (allowed_origins, failed_origins) = AllowedOrigins::some(&["https://www.acme.com"]); assert!(failed_origins.is_empty()); // You can also deserialize this - let options = rocket_cors::Cors { + let cors = rocket_cors::CorsOptions { allowed_origins: allowed_origins, allowed_methods: vec![Method::Get].into_iter().map(From::from).collect(), allowed_headers: AllowedHeaders::some(&["Authorization", "Accept"]), allow_credentials: true, ..Default::default() - }; + } + .to_cors()?; rocket::ignite() .mount("/", routes![cors]) - .attach(options) + .attach(cors) .launch(); + + Ok(()) }