From 4dbd87a36fcd735a007c81ec2bd15a1551a58529 Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Wed, 31 Oct 2018 13:29:22 -0700 Subject: [PATCH] New version: 0.4.0-rc.1. --- CHANGELOG.md | 385 +++++++++++++++++++++++++ contrib/codegen/Cargo.toml | 4 +- contrib/codegen/build.rs | 56 ++++ contrib/lib/Cargo.toml | 6 +- contrib/lib/src/databases.rs | 2 +- contrib/lib/src/lib.rs | 2 +- contrib/lib/src/templates/mod.rs | 2 +- core/codegen/Cargo.toml | 8 +- core/codegen/build.rs | 56 ++++ core/codegen/src/lib.rs | 2 +- core/http/Cargo.toml | 4 +- core/lib/Cargo.toml | 6 +- core/lib/src/lib.rs | 2 +- scripts/config.sh | 4 +- site/guide/1-quickstart.md | 2 +- site/guide/10-pastebin.md | 4 +- site/guide/2-getting-started.md | 2 +- site/guide/6-state.md | 2 +- site/guide/9-configuration.md | 2 +- site/index.toml | 4 +- site/news/2018-10-31-version-0.4-rc.md | 41 +++ site/news/index.toml | 20 ++ 22 files changed, 587 insertions(+), 29 deletions(-) create mode 100644 contrib/codegen/build.rs create mode 100644 core/codegen/build.rs create mode 100644 site/news/2018-10-31-version-0.4-rc.md diff --git a/CHANGELOG.md b/CHANGELOG.md index a7fc4782..8a2c4f76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,387 @@ +# Version 0.4.0-rc.1 (Oct 31, 2018) + +## New Features + +This release includes the following new features: + + * Introduced [Typed URIs]. + * Introduced [ORM agnostic database support]. + * Introduced [Request-Local State]. + * Introduced mountable static-file serving via [`StaticFiles`]. + * Introduced automatic [live template reloading]. + * Introduced custom stateful handlers via [`Handler`]. + * Introduced [transforming] data guards via [`FromData::transform()`]. + * Introduced revamped [query string handling]. + * Added [derive for `FromFormValue`]. + * Added [derive for `Responder`]. + * Added [`Template::custom()`] for customizing templating engines including + registering filters and helpers. + * Cookies are automatically tracked and propagated by [`Client`]. + * Private cookies can be added to local requests with + [`LocalRequest::private_cookie()`]. + * Release builds default to the `production` environment. + * Keep-alive can be configured via the `keep_alive` configuration parameter. + * Allow CLI colors and emoji to be disabled with `ROCKET_CLI_COLORS=off`. + * Route `format` accepts [shorthands] such as `json` and `html`. + * Implemented [`Responder` for `Status`]. + * Added [`Response::cookies()`] for retrieving response cookies. + * All logging is disabled when `log` is set to `off`. + * Added [`Metadata`] guard for retrieving templating information. + * The [`Uri`] type parses URIs according to RFC 7230 into one of [`Origin`], + [`Absolute`], or [`Authority`]. + * Added [`Outcome::and_then()`], [`Outcome::failure_then()`], and + [`Outcome::forward_then()`]. + * Implemented `Responder` for `&[u8]`. + * Any `T: Into>` can be [`mount()`]ed. + * [Default rankings] range from -6 to -1, differentiating on static query + strings. + * Added [`Request::get_query_value()`] for retrieving a query value by key. + +[Typed URIs]: https://rocket.rs/v0.4/guide/responses/#typed-uris +[ORM agnostic database support]: https://rocket.rs/v0.4/guide/state/#databases +[`Template::custom()`]: https://api.rocket.rs/v0.4/rocket_contrib/templates/struct.Template.html#method.custom +[`LocalRequest::private_cookie()`]: https://api.rocket.rs/v0.4/rocket/local/struct.LocalRequest.html#method.private_cookie +[`LocalRequest`]: https://api.rocket.rs/v0.4/rocket/local/struct.LocalRequest.html +[shorthands]: https://api.rocket.rs/v0.4/rocket/http/struct.ContentType.html#method.parse_flexible +[derive for `FromFormValue`]: https://api.rocket.rs/v0.4/rocket_codegen/derive.FromFormValue.html +[derive for `Responder`]: https://api.rocket.rs/v0.4/rocket_codegen/derive.Responder.html +[`Response::cookies()`]: https://api.rocket.rs/v0.4/rocket/struct.Response.html#method.cookies +[`Client`]: https://api.rocket.rs/v0.4/rocket/local/struct.Client.html +[Request-Local State]: https://rocket.rs/v0.4/guide/state/#request-local-state +[`Metadata`]: https://api.rocket.rs/v0.4/rocket_contrib/templates/struct.Metadata.html +[`Uri`]: https://api.rocket.rs/v0.4/rocket/http/uri/enum.Uri.html +[`Origin`]: https://api.rocket.rs/v0.4/rocket/http/uri/struct.Origin.html +[`Absolute`]: https://api.rocket.rs/v0.4/rocket/http/uri/struct.Absolute.html +[`Authority`]: https://api.rocket.rs/v0.4/rocket/http/uri/struct.Authority.html +[`Outcome::and_then()`]: https://api.rocket.rs/v0.4/rocket/enum.Outcome.html#method.and_then +[`Outcome::forward_then()`]: https://api.rocket.rs/v0.4/rocket/enum.Outcome.html#method.forward_then +[`Outcome::failure_then()`]: https://api.rocket.rs/v0.4/rocket/enum.Outcome.html#method.failure_then +[`StaticFiles`]: https://api.rocket.rs/v0.4/rocket_contrib/serve/struct.StaticFiles.html +[live template reloading]: https://rocket.rs/v0.4/guide/responses/#live-reloading +[`Handler`]: https://api.rocket.rs/v0.4/rocket/trait.Handler.html +[`mount()`]: https://api.rocket.rs/v0.4/rocket/struct.Rocket.html#method.mount +[`FromData::transform()`]: https://api.rocket.rs/v0.4/rocket/data/trait.FromData.html#tymethod.transform +[transforming]: https://api.rocket.rs/v0.4/rocket/data/trait.FromData.html#transforming +[query string handling]: https://rocket.rs/v0.4/guide/requests/#query-strings +[Default rankings]: https://rocket.rs/v0.4/guide/requests/#default-ranking +[`Request::get_query_value()`]: https://api.rocket.rs/v0.4/rocket/struct.Request.html#method.get_query_value +[`Responder` for `Status`]: https://rocket.rs/v0.4/guide/responses/#status + +## Codegen Rewrite + +The [`rocket_codegen`] crate has been entirely rewritten using to-be-stable +procedural macro APIs. We expect nightly breakages to drop dramatically, likely +to zero, as a result. The new prelude import for Rocket applications is: + +```diff +- #![feature(plugin)] +- #![plugin(rocket_codegen)] ++ #![feature(proc_macro_hygiene, decl_macro)] + +- extern crate rocket; ++ #[macro_use] extern crate rocket; +``` + +The [`rocket_codegen`] crate should **_not_** be a direct dependency. Remove it +from your `Cargo.toml`: + +```diff +[dependencies] +- rocket = "0.3" ++ rocket = "0.4" +- rocket_codegen = "0.3" +``` + +[`rocket_codegen`]: https://api.rocket.rs/v0.4/rocket_codegen/index.html + +## Breaking Changes + +This release includes many breaking changes. These changes are listed below +along with a short note about how to handle the breaking change in existing +applications when applicable. + + * **[`LaunchErrorKind::Collision`] contains a vector of the colliding routes.** + + Destruct using `LaunchErrorKind::Collision(..)` to ignore the vector. + + * **[`json!`] returns a [`JsonValue`], no longer needs wrapping.** + + Change instances of `Json(json!(..))` to `json!` and change the + corresponding type to `JsonValue`. + + * **[`ring`] was updated to 0.13.** + + Ensure all transitive dependencies to `ring` refer to version `0.13`. + + * **TLS certificates require the `subjectAltName` extension.** + + Ensure that your TLS certificates contain the `subjectAltName` extension + with a value set to your domain. + + * **Route paths, mount points, and [`LocalRequest`] URIs are strictly + checked.** + + Ensure your mount points are absolute paths with no parameters, ensure your + route paths are absolute paths with proper parameter syntax, and ensure that + paths passed to `LocalRequest` are valid. + + * **[`Template::show()`] takes an `&Rocket`, doesn't accept a `root`.** + + Use [`client.rocket()`] to get a reference to an instance of `Rocket` when + testing. Use [`Template::render()`] in routes. + + * **[`Request::remote()`] returns the _actual_ remote IP, doesn't rewrite.** + + Use [`Request::real_ip()`] or [`Request::client_ip()`] to retrieve the IP + address from the "X-Real-IP" header if it is present. + + * **Release builds default to the production environment.** + + Manually set the environment to `debug` with `ROCKET_ENV=debug` for the + previous behavior. + + * **All environments default to port 8000.** + + Manually configure a port of `80` for the `stage` and `production` + environments for the previous behavior. + + * **[`Bind`] variant was added to [`LaunchErrorKind`].** + + Ensure matches on `LaunchErrorKind` include or ignore the `Bind` variant. + + * **Cookies are automatically tracked and propagated by [`Client`].** + + For the previous behavior, construct a `Client` with + [`Client::untracked()`]. + + * **`UUID` was renamed to [`Uuid`].** + + Use `Uuid` instead of `UUID`. + + * **The `#[error]` attribute and `errors!` macro were removed.** + + Use `#[catch]` and `catchers!` instead. + + * **`Rocket::catch()` was renamed to [`Rocket::register()`].** + + Change calls of the form `.catch(errors![..])` to + `.register(catchers![..])`. + + * **The `#[catch]` attribute only accepts functions with 0 or 1 argument.** + + Ensure the argument to the catcher, if any, is of type `&Request`. + + * **`LocalRequest::cloned_dispatch()` was removed.** + + Chain calls to `.clone().dispatch()` for the previous behavior. + + * **`Uri` was largely replaced by [`Origin`].** + + In general, replace the type `Uri` with `Origin`. The `base` and `uri` + fields of [`Route`] are now of type [`Origin`]. The `&Uri` guard is now + `&Origin`. [`Request::uri()`] now returns an [`Origin`]. + + * **[`Redirect`] constructors take a generic type of `T: + TryInto>`.** + + A call to a `Redirect` constructor with a non-`'static` `&str` of the form + `Redirect::to(string)` should become `Redirect::to(string.to_string())`, + heap-allocating the string before being passed to the constructor. + + * **The [`FromData`] impl for [`Form`] and [`LenientForm`] now return an error + of type [`FormDataError`].** + + On non-I/O errors, the form string is stored in the variant as an `&'f str`. + + * **[`Missing`] variant was added to [`ConfigError`].** + + Ensure matches on `ConfigError` include or ignore the `Missing` variant. + + * **Route and catcher attributes respect function privacy.** + + To mount a route or register a catcher outside of the module it is declared, + ensure that the handler function is marked `pub` or `crate`. + + * **The [`FromData`] impl for [`Json`] now returns an error of type + [`JsonError`].** + + The previous `SerdeError` is now the `.1` member of the `JsonError` `enum`. + Match and destruct the variant for the previous behavior. + + * **[`FromData`] is now emulated by [`FromDataSimple`].** + + Change _implementations_, not uses, of `FromData` to `FromDataSimple`. + Consider whether your implementation could benefit from [transformations]. + + * **[`Form`] and [`LenientForm`] lost a lifetime parameter, `get()` method.** + + Change a type of `Form<'a, T<'a>>` to `Form` or `Form>`. `Form` + and `LenientForm` now implement `Deref`, allowing for calls + to `.get()` to be removed. + + * **Query handling syntax has been completely revamped.** + + A query parameter of `` is now ``. Consider whether your + application benefits from the revamped [query string handling]. + + * **[`FormItems`] iterates over values of type [`FormItem`].** + + Map using `.map(|item| item.key_value())` for the previous behavior. + + * **All items in [`rocket_contrib`] are namespaced behind modules.** + + * `Json` is now `json::Json` + * `MsgPack` is now `msgpack::MsgPack` + * `MsgPackError` is now `msgpack::Error` + * `Template` is now `templates::Template` + * `UUID` is now `uuid::Uuid` + * `Value` is replaced by `json::JsonValue` + + * **[`Request::get_param()`] and [`Request::get_segments()`] are indexed by + _segment_, not dynamic parameter.** + + Modify the `n` argument in calls to these functions appropriately. + + * **Method-based route attributes no longer accept a keyed `path` parameter.** + + Change an attribute of the form `#[get(path = "..")]` to `#[get("..")]`. + + * **[`Json`] and [`MsgPack`] data guards no longer reject requests with an + unexpected Content-Type** + + To approximate the previous behavior, add a `format = "json"` route + parameter when using `Json` or `format = "msgpack"` when using `MsgPack`. + + * **Implemented [`Responder` for `Status`]. Removed `Failure`, + `status::NoContent`, and `status::Reset` responders.** + + Replace uses of `Failure(status)` with `status` directly. Replace + `status::NoContent` with `Status::NoContent`. Replace `status::Reset` with + `Status::ResetContent`. + + * **[`Status::new()`] is no longer `const`.** + + * **[`Json`] no longer has a default value for its type parameter.** + + * **Using `data` on a non-payload method route is a warning instead of error.** + + * **The `raw_form_string` method of [`Form`] and [`LenientForm`] was + removed.** + + * **Various impossible `Error` associated types are now set to `!`.** + + * **All [`AdHoc`] constructors require a name as the first parameter.** + + * **The top-level `Error` type was removed.** + +[`LaunchErrorKind::Collision`]: https://api.rocket.rs/v0.4/rocket/error/enum.LaunchErrorKind.html#variant.Collision +[`json!`]: https://api.rocket.rs/v0.4/rocket_contrib/macro.json.html +[`JsonValue`]: https://api.rocket.rs/v0.4/rocket_contrib/json/struct.JsonValue.html +[`Json`]: https://api.rocket.rs/v0.4/rocket_contrib/json/struct.Json.html +[`ring`]: https://crates.io/crates/ring +[`Template::show()`]: https://api.rocket.rs/v0.4/rocket_contrib/templates/struct.Template.html#method.show +[`Template::render()`]: https://api.rocket.rs/v0.4/rocket_contrib/templates/struct.Template.html#method.render +[`client.rocket()`]: https://api.rocket.rs/v0.4/rocket/local/struct.Client.html#method.rocket +[`Request::remote()`]: https://api.rocket.rs/v0.4/rocket/struct.Request.html#method.remote +[`Request::real_ip()`]: https://api.rocket.rs/v0.4/rocket/struct.Request.html#method.real_ip +[`Request::client_ip()`]: https://api.rocket.rs/v0.4/rocket/struct.Request.html#method.client_ip +[`Bind`]: https://api.rocket.rs/v0.4/rocket/error/enum.LaunchErrorKind.html#variant.Bind +[`LaunchErrorKind`]: https://api.rocket.rs/v0.4/rocket/error/enum.LaunchErrorKind.html +[`Client::untracked()`]: https://api.rocket.rs/v0.4/rocket/local/struct.Client.html#method.untracked +[`Uuid`]: https://api.rocket.rs/v0.4/rocket_contrib/uuid/struct.Uuid.html +[`Route`]: https://api.rocket.rs/v0.4/rocket/struct.Route.html +[`Redirect`]: https://api.rocket.rs/v0.4/rocket/response/struct.Redirect.html +[`Request::uri()`]: https://api.rocket.rs/v0.4/rocket/struct.Request.html#method.uri +[`FormDataError`]: https://api.rocket.rs/v0.4/rocket/request/enum.FormDataError.html +[`FromData`]: https://api.rocket.rs/v0.4/rocket/data/trait.FromData.html +[`Form`]: https://api.rocket.rs/v0.4/rocket/request/struct.Form.html +[`LenientForm`]: https://api.rocket.rs/v0.4/rocket/request/struct.LenientForm.html +[`AdHoc`]: https://api.rocket.rs/v0.4/rocket/fairing/struct.AdHoc.html +[`Missing`]: https://api.rocket.rs/v0.4/rocket/config/enum.ConfigError.html#variant.Missing +[`ConfigError`]: https://api.rocket.rs/v0.4/rocket/config/enum.ConfigError.html +[`Rocket::register()`]: https://api.rocket.rs/v0.4/rocket/struct.Rocket.html#method.register +[`JsonError`]: https://api.rocket.rs/v0.4/rocket_contrib/json/enum.JsonError.html +[transformations]: https://api.rocket.rs/v0.4/rocket/data/trait.FromData.html#transforming +[`FromDataSimple`]: https://api.rocket.rs/v0.4/rocket/data/trait.FromDataSimple.html +[`Request::get_param()`]: https://api.rocket.rs/v0.4/rocket/struct.Request.html#method.get_param +[`Request::get_segments()`]: https://api.rocket.rs/v0.4/rocket/struct.Request.html#method.get_segments +[`FormItem`]: https://api.rocket.rs/v0.4/rocket/request/struct.FormItem.html +[`rocket_contrib`]: https://api.rocket.rs/v0.4/rocket_contrib/index.html +[`MsgPack`]: https://api.rocket.rs/v0.4/rocket_contrib/msgpack/struct.MsgPack.html +[`Status::new()`]: https://api.rocket.rs/v0.4/rocket/http/struct.Status.html#method.new + +## General Improvements + +In addition to new features, Rocket saw the following improvements: + + * Log messages now refer to routes by name. + * Collision errors on launch name the colliding routes. + * Launch fairing failures refer to the failing fairing by name. + * The default `403` catcher now references authorization, not authentication. + * Private cookies are set to `HttpOnly` and are given an expiration date of 1 + week by default. + * A [Tera templates example] was added. + * Invalid client requests receive a response of `400` instead of `500`. + * Response bodies are reliably stripped on `HEAD` requests. + * Added a default catcher for `504: Gateway Timeout`. + * Configuration information is logged in all environments. + * Use of `unsafe` was reduced from 9 to 2 in core library. + * [`FormItems`] now parses empty keys and values as well as keys without + values. + * Added [`Config::active()`] as a shorthand for + `Config::new(Environment::active()?)`. + * Address/port binding errors at launch are detected and explicitly emitted. + * [`Flash`] cookies are cleared only after they are inspected. + * `Sync` bound on [`AdHoc::on_attach()`], [`AdHoc::on_launch()`] was removed. + * [`AdHoc::on_attach()`], [`AdHoc::on_launch()`] accept an `FnOnce`. + * Added [`Config::root_relative()`] for retrieving paths relative to the + configuration file. + * Added [`Config::tls_enabled()`] for determining whether TLS is actively + enabled. + * ASCII color codes are not emitted on versions of Windows that do not support + them. + * Added FLAC (`audio/flac`), Icon (`image/x-icon`), WEBA (`audio/webm`), TIFF + (`image/tiff`), AAC (`audio/aac`), Calendar (`text/calendar`), MPEG + (`video/mpeg`), TAR (`application/x-tar`), GZIP (`application/gzip`), MOV + (`video/quicktime`), MP4 (`video/mp4`) as known media types. + * Added `.weba` (`WEBA`), `.ogv` (`OGG`), `.mp4` (`MP4`), `.mpeg4` (`MP4`), + `.aac` (`AAC`), `.ics` (`Calendar`), `.bin` (`Binary`), `.mpg` (`MPEG`), + `.mpeg` (`MPEG`), `.tar` (`TAR`), `.gz` (`GZIP`), `.tif` (`TIFF`), `.tiff` + (`TIFF`), `.mov` (`MOV`) as known extensions. + * Interaction between route attributes and declarative macros has been + improved. + * Generated code now logs through logging infrastructures as opposed to using + `println!`. + * Routing has been optimized by caching routing metadata. + * All macros, derives, and attributes are individually documented in + [`rocket_codegen`]. + * The `log` dependency was updated to `0.4`. + * The `handlebars` dependency was updated to `1.0`. + * The `tera` dependency was updated to `0.11`. + * The `uuid` dependency was updated to `0.7`. + * The `rustls` dependency was updated to `0.14`. + * The `cookie` dependency was updated to `0.11`. + +[Tera templates example]: https://github.com/SergioBenitez/Rocket/tree/v0.4/examples/tera_templates +[`FormItems`]: https://api.rocket.rs/v0.4/rocket/request/enum.FormItems.html +[`Config::active()`]: https://api.rocket.rs/v0.4/rocket/config/struct.Config.html#method.active +[`Flash`]: https://api.rocket.rs/v0.4/rocket/response/struct.Flash.html +[`AdHoc::on_attach()`]: https://api.rocket.rs/v0.4/rocket/fairing/struct.AdHoc.html#method.on_attach +[`AdHoc::on_launch()`]: https://api.rocket.rs/v0.4/rocket/fairing/struct.AdHoc.html#method.on_launch +[`Config::root_relative()`]: https://api.rocket.rs/v0.4/rocket/struct.Config.html#method.root_relative +[`Config::tls_enabled()`]: https://api.rocket.rs/v0.4/rocket/struct.Config.html#method.tls_enabled +[`rocket_codegen`]: https://api.rocket.rs/v0.4/rocket_codegen/index.html + +## Infrastructure + + * All documentation is versioned. + * Previous, current, and development versions of all documentation are hosted. + * The repository was reorganized with top-level directories of `core` and + `contrib`. + * The `http` module was split into its own `rocket_http` crate. This is an + internal change only. + * All uses of `unsafe` are documented with informal proofs of correctness. + # Version 0.3.16 (Aug 24, 2018) ## Codegen @@ -498,6 +882,7 @@ In addition to new features, Rocket saw the following improvements: * Console logging for table-based config values is improved. * `PartialOrd`, `Ord`, and `Hash` are now implemented for [`State`]. * The format of a request is always logged when available. + * Route matching on `format` now functions as documented. [`yansi`]: https://crates.io/crates/yansi [`Request`]: https://api.rocket.rs/v0.3/rocket/struct.Request.html diff --git a/contrib/codegen/Cargo.toml b/contrib/codegen/Cargo.toml index 29a9a25b..3b2cafd4 100644 --- a/contrib/codegen/Cargo.toml +++ b/contrib/codegen/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rocket_contrib_codegen" -version = "0.4.0-dev" +version = "0.4.0-rc.1" authors = ["Sergio Benitez "] description = "Procedural macros for the Rocket contrib libraries." documentation = "https://api.rocket.rs/v0.4/rocket_contrib/" @@ -9,7 +9,7 @@ repository = "https://github.com/SergioBenitez/Rocket" readme = "../../README.md" keywords = ["rocket", "contrib", "code", "generation", "proc-macro"] license = "MIT/Apache-2.0" -build = "../../core/lib/build.rs" +build = "build.rs" [features] database_attribute = [] diff --git a/contrib/codegen/build.rs b/contrib/codegen/build.rs new file mode 100644 index 00000000..26947f5a --- /dev/null +++ b/contrib/codegen/build.rs @@ -0,0 +1,56 @@ +//! This tiny build script ensures that rocket is not compiled with an +//! incompatible version of rust. + +extern crate yansi; +extern crate version_check; + +use yansi::Color::{Red, Yellow, Blue, White}; +use version_check::{supports_features, is_min_version, is_min_date}; + +// Specifies the minimum nightly version needed to compile Rocket. +const MIN_DATE: &'static str = "2018-10-05"; +const MIN_VERSION: &'static str = "1.31.0-nightly"; + +fn main() { + let ok_channel = supports_features(); + let ok_version = is_min_version(MIN_VERSION); + let ok_date = is_min_date(MIN_DATE); + let triple = (ok_channel, ok_version, ok_date); + + let print_version_err = |version: &str, date: &str| { + eprintln!("{} {}. {} {}.", + White.paint("Installed version is:"), + Yellow.paint(format!("{} ({})", version, date)), + White.paint("Minimum required:"), + Yellow.paint(format!("{} ({})", MIN_VERSION, MIN_DATE))); + }; + + if let (Some(ok_channel), Some((ok_version, version)), Some((ok_date, date))) = triple { + if !ok_channel { + eprintln!("{} {}", + Red.paint("Error:").bold(), + White.paint("Rocket requires a nightly or dev version of Rust.")); + print_version_err(&*version, &*date); + eprintln!("{}{}{}", + Blue.paint("See the getting started guide ("), + White.paint("https://rocket.rs/v0.4/guide/getting-started/"), + Blue.paint(") for more information.")); + panic!("Aborting compilation due to incompatible compiler.") + } + + if !ok_version || !ok_date { + eprintln!("{} {}", + Red.paint("Error:").bold(), + White.paint("Rocket requires a more recent version of rustc.")); + eprintln!("{}{}{}", + Blue.paint("Use `"), + White.paint("rustup update"), + Blue.paint("` or your preferred method to update Rust.")); + print_version_err(&*version, &*date); + panic!("Aborting compilation due to incompatible compiler.") + } + } else { + println!("cargo:warning={}", "Rocket was unable to check rustc compatibility."); + println!("cargo:warning={}", "Build may fail due to incompatible rustc version."); + } +} diff --git a/contrib/lib/Cargo.toml b/contrib/lib/Cargo.toml index eac96369..992766bb 100644 --- a/contrib/lib/Cargo.toml +++ b/contrib/lib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rocket_contrib" -version = "0.4.0-dev" +version = "0.4.0-rc.1" authors = ["Sergio Benitez "] description = "Community contributed libraries for the Rocket web framework." documentation = "https://api.rocket.rs/v0.4/rocket_contrib/" @@ -35,8 +35,8 @@ redis_pool = ["databases", "redis", "r2d2_redis"] [dependencies] # Global dependencies. -rocket_contrib_codegen = { version = "0.4.0-rc", path = "../codegen", optional = true } -rocket = { version = "0.4.0-rc", path = "../../core/lib/" } +rocket_contrib_codegen = { version = "0.4.0-rc.1", path = "../codegen", optional = true } +rocket = { version = "0.4.0-rc.1", path = "../../core/lib/" } log = "0.4" # Serialization and templating dependencies. diff --git a/contrib/lib/src/databases.rs b/contrib/lib/src/databases.rs index 16c3a6de..a312599c 100644 --- a/contrib/lib/src/databases.rs +++ b/contrib/lib/src/databases.rs @@ -32,7 +32,7 @@ //! //! ```toml //! [dependencies.rocket_contrib] -//! version = "0.4.0-dev" +//! version = "0.4.0-rc.1" //! default-features = false //! features = ["diesel_sqlite_pool"] //! ``` diff --git a/contrib/lib/src/lib.rs b/contrib/lib/src/lib.rs index 44ab03a5..8ff47c60 100644 --- a/contrib/lib/src/lib.rs +++ b/contrib/lib/src/lib.rs @@ -32,7 +32,7 @@ //! //! ```toml //! [dependencies.rocket_contrib] -//! version = "0.4.0-dev" +//! version = "0.4.0-rc.1" //! default-features = false //! features = ["json"] //! ``` diff --git a/contrib/lib/src/templates/mod.rs b/contrib/lib/src/templates/mod.rs index 55435687..68b5048c 100644 --- a/contrib/lib/src/templates/mod.rs +++ b/contrib/lib/src/templates/mod.rs @@ -9,7 +9,7 @@ //! //! ```toml //! [dependencies.rocket_contrib] -//! version = 0.4.0-dev +//! version = 0.4.0-rc.1 //! default-features = false //! features = ["handlebars_templates", "tera_templates"] //! ``` diff --git a/core/codegen/Cargo.toml b/core/codegen/Cargo.toml index f7de3509..75642aa6 100644 --- a/core/codegen/Cargo.toml +++ b/core/codegen/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rocket_codegen" -version = "0.4.0-dev" +version = "0.4.0-rc.1" authors = ["Sergio Benitez "] description = "Procedural macros for the Rocket web framework." documentation = "https://api.rocket.rs/v0.4/rocket_codegen/" @@ -9,7 +9,7 @@ repository = "https://github.com/SergioBenitez/Rocket" readme = "../../README.md" keywords = ["rocket", "web", "framework", "code", "generation"] license = "MIT/Apache-2.0" -build = "../lib/build.rs" +build = "build.rs" [lib] proc-macro = true @@ -17,7 +17,7 @@ proc-macro = true [dependencies] indexmap = "1.0" quote = "0.6.1" -rocket_http = { version = "0.4.0-dev", path = "../http/" } +rocket_http = { version = "0.4.0-rc.1", path = "../http/" } devise = "0.1" [build-dependencies] @@ -25,5 +25,5 @@ yansi = "0.4" version_check = "0.1.3" [dev-dependencies] -rocket = { version = "0.4.0-dev", path = "../lib" } +rocket = { version = "0.4.0-rc.1", path = "../lib" } compiletest_rs = { git = "https://github.com/laumann/compiletest-rs" } diff --git a/core/codegen/build.rs b/core/codegen/build.rs new file mode 100644 index 00000000..26947f5a --- /dev/null +++ b/core/codegen/build.rs @@ -0,0 +1,56 @@ +//! This tiny build script ensures that rocket is not compiled with an +//! incompatible version of rust. + +extern crate yansi; +extern crate version_check; + +use yansi::Color::{Red, Yellow, Blue, White}; +use version_check::{supports_features, is_min_version, is_min_date}; + +// Specifies the minimum nightly version needed to compile Rocket. +const MIN_DATE: &'static str = "2018-10-05"; +const MIN_VERSION: &'static str = "1.31.0-nightly"; + +fn main() { + let ok_channel = supports_features(); + let ok_version = is_min_version(MIN_VERSION); + let ok_date = is_min_date(MIN_DATE); + let triple = (ok_channel, ok_version, ok_date); + + let print_version_err = |version: &str, date: &str| { + eprintln!("{} {}. {} {}.", + White.paint("Installed version is:"), + Yellow.paint(format!("{} ({})", version, date)), + White.paint("Minimum required:"), + Yellow.paint(format!("{} ({})", MIN_VERSION, MIN_DATE))); + }; + + if let (Some(ok_channel), Some((ok_version, version)), Some((ok_date, date))) = triple { + if !ok_channel { + eprintln!("{} {}", + Red.paint("Error:").bold(), + White.paint("Rocket requires a nightly or dev version of Rust.")); + print_version_err(&*version, &*date); + eprintln!("{}{}{}", + Blue.paint("See the getting started guide ("), + White.paint("https://rocket.rs/v0.4/guide/getting-started/"), + Blue.paint(") for more information.")); + panic!("Aborting compilation due to incompatible compiler.") + } + + if !ok_version || !ok_date { + eprintln!("{} {}", + Red.paint("Error:").bold(), + White.paint("Rocket requires a more recent version of rustc.")); + eprintln!("{}{}{}", + Blue.paint("Use `"), + White.paint("rustup update"), + Blue.paint("` or your preferred method to update Rust.")); + print_version_err(&*version, &*date); + panic!("Aborting compilation due to incompatible compiler.") + } + } else { + println!("cargo:warning={}", "Rocket was unable to check rustc compatibility."); + println!("cargo:warning={}", "Build may fail due to incompatible rustc version."); + } +} diff --git a/core/codegen/src/lib.rs b/core/codegen/src/lib.rs index ab518799..3c71ca13 100644 --- a/core/codegen/src/lib.rs +++ b/core/codegen/src/lib.rs @@ -23,7 +23,7 @@ //! //! ```toml //! [dependencies] -//! rocket = "0.4.0-dev" +//! rocket = "0.4.0-rc.1" //! ``` //! //! And to import all macros, attributes, and derives via `#[macro_use]` in the diff --git a/core/http/Cargo.toml b/core/http/Cargo.toml index 029d6902..bbec63f3 100644 --- a/core/http/Cargo.toml +++ b/core/http/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rocket_http" -version = "0.4.0-dev" +version = "0.4.0-rc.1" authors = ["Sergio Benitez "] description = """ Types, traits, and parsers for HTTP requests, responses, and headers. @@ -34,4 +34,4 @@ features = ["server"] optional = true [dev-dependencies] -rocket = { version = "0.4.0-dev", path = "../lib" } +rocket = { version = "0.4.0-rc.1", path = "../lib" } diff --git a/core/lib/Cargo.toml b/core/lib/Cargo.toml index 985b4f43..5779a8e2 100644 --- a/core/lib/Cargo.toml +++ b/core/lib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rocket" -version = "0.4.0-dev" +version = "0.4.0-rc.1" authors = ["Sergio Benitez "] description = """ Web framework for nightly with a focus on ease-of-use, expressibility, and speed. @@ -18,8 +18,8 @@ categories = ["web-programming::http-server"] tls = ["rocket_http/tls"] [dependencies] -rocket_codegen = { version = "0.4.0-dev", path = "../codegen" } -rocket_http = { version = "0.4.0-dev", path = "../http" } +rocket_codegen = { version = "0.4.0-rc.1", path = "../codegen" } +rocket_http = { version = "0.4.0-rc.1", path = "../http" } yansi = "0.4" log = "0.4" toml = "0.4.7" diff --git a/core/lib/src/lib.rs b/core/lib/src/lib.rs index c91a332f..a6dea9e2 100644 --- a/core/lib/src/lib.rs +++ b/core/lib/src/lib.rs @@ -47,7 +47,7 @@ //! //! ```toml //! [dependencies] -//! rocket = "0.4.0-dev" +//! rocket = "0.4.0-rc.1" //! ``` //! //! Then, add the following to the top of your `main.rs` file: diff --git a/scripts/config.sh b/scripts/config.sh index 6a70947f..0f961d3f 100755 --- a/scripts/config.sh +++ b/scripts/config.sh @@ -24,9 +24,9 @@ function relative() { } # Full and major version of Rocket -ROCKET_VERSION="0.4.0-dev" +ROCKET_VERSION="0.4.0-rc.1" ROCKET_MAJOR_VERSION="0.4" -CURRENT_RELEASE=false +CURRENT_RELEASE=true # Root of workspace-like directories. PROJECT_ROOT=$(relative "") || exit $? diff --git a/site/guide/1-quickstart.md b/site/guide/1-quickstart.md index be35b30a..15c4b214 100644 --- a/site/guide/1-quickstart.md +++ b/site/guide/1-quickstart.md @@ -15,7 +15,7 @@ For instance, the following set of commands runs the `hello_world` example: ```sh git clone https://github.com/SergioBenitez/Rocket cd Rocket -git checkout v0.4.0-dev +git checkout v0.4.0-rc.1 cd examples/hello_world cargo run ``` diff --git a/site/guide/10-pastebin.md b/site/guide/10-pastebin.md index 54080562..61b32f67 100644 --- a/site/guide/10-pastebin.md +++ b/site/guide/10-pastebin.md @@ -43,8 +43,8 @@ Then add the usual Rocket dependencies to the `Cargo.toml` file: ```toml [dependencies] -rocket = "0.4.0-dev" -rocket_codegen = "0.4.0-dev" +rocket = "0.4.0-rc.1" +rocket_codegen = "0.4.0-rc.1" ``` And finally, create a skeleton Rocket application to work off of in diff --git a/site/guide/2-getting-started.md b/site/guide/2-getting-started.md index 1ddf51bb..f821033b 100644 --- a/site/guide/2-getting-started.md +++ b/site/guide/2-getting-started.md @@ -50,7 +50,7 @@ Now, add Rocket as a dependency in your `Cargo.toml`: ``` [dependencies] -rocket = "0.4.0-dev" +rocket = "0.4.0-rc.1" ``` Modify `src/main.rs` so that it contains the code for the Rocket `Hello, world!` diff --git a/site/guide/6-state.md b/site/guide/6-state.md index 7e57177c..62c3c940 100644 --- a/site/guide/6-state.md +++ b/site/guide/6-state.md @@ -215,7 +215,7 @@ databases, you'd write in `Cargo.toml`: ```toml [dependencies.rocket_contrib] -version = "0.4.0-dev" +version = "0.4.0-rc.1" default-features = false features = ["diesel_sqlite_pool"] ``` diff --git a/site/guide/9-configuration.md b/site/guide/9-configuration.md index e4c9c5c9..1d93d772 100644 --- a/site/guide/9-configuration.md +++ b/site/guide/9-configuration.md @@ -276,7 +276,7 @@ dependency in your `Cargo.toml` file: ``` [dependencies] -rocket = { version = "0.4.0-dev", features = ["tls"] } +rocket = { version = "0.4.0-rc.1", features = ["tls"] } ``` TLS is configured through the `tls` configuration parameter. The value of `tls` diff --git a/site/index.toml b/site/index.toml index bbe3816e..223da92e 100644 --- a/site/index.toml +++ b/site/index.toml @@ -3,8 +3,8 @@ ############################################################################### [release] -version = "0.4.0-dev" -date = "Oct 28, 2018" +version = "0.4.0-rc.1" +date = "Oct 31, 2018" ############################################################################### # Top features: displayed in the header under the introductory text. diff --git a/site/news/2018-10-31-version-0.4-rc.md b/site/news/2018-10-31-version-0.4-rc.md new file mode 100644 index 00000000..8a2b9dac --- /dev/null +++ b/site/news/2018-10-31-version-0.4-rc.md @@ -0,0 +1,41 @@ +# Rocket v0.4 Release Candidate + + + +I am delighted to announce that a release candidate for Rocket v0.4 is available +today! This release brings over a year of features, improvements, and +refinements, resolving some of the most called for requests and bringing Rocket +measurably closer to stable compatibility. + +The release candidate is an opportunity to discover issues with Rocket v0.4 and +its documentation before its general release. We encourage all users to migrate +their applications to the release candidate and report any issues to the [GitHub +issue tracker]. + +Barring any major issues, the general release of Rocket v0.4 is planned for +Friday, November 9th, when we'll post a full news article covering the biggest +features and changes in Rocket v0.4. Until then, the [CHANGELOG] contains every +feature addition, change, and improvement since v0.3, as well as information on +migrating your applications to v0.4. All documentation, including the [guide] +and [API docs], has been updated in full for v0.4. + +We're excited for your feedback, and we look forward to seeing you again on +Friday, November 9th for the general release! + +[GitHub issue tracker]: https://github.com/SergioBenitez/Rocket/issues +[API docs]: https://api.rocket.rs/v0.4/rocket/ +[guide]: ../../guide +[CHANGELOG]: https://github.com/SergioBenitez/Rocket/tree/v0.4/CHANGELOG.md#version-040-rc-oct-31-2018 + +## About Rocket + +Rocket is a web framework for Rust with a focus on ease of use, expressibility, +and speed. Rocket makes it simple to write fast web applications without +sacrificing flexibility or type safety. All with minimal code. + +Not already using Rocket? Join the tens of thousands of users and hundreds of +companies happily using Rocket today! Rocket's extensive documentation makes it +easy. Get started now by [reading through the guide](../../guide) or learning +more from [the overview](../../overview). diff --git a/site/news/index.toml b/site/news/index.toml index 2af65223..1f9a7695 100644 --- a/site/news/index.toml +++ b/site/news/index.toml @@ -1,3 +1,23 @@ +[[articles]] +title = "Rocket v0.4 Release Candidate" +slug = "2018-10-31-version-0.4-rc" +author = "Sergio Benitez" +author_url = "https://sergio.bz" +date = "October 31, 2018" +snippet = """ +I am delighted to announce that a release candidate for Rocket v0.4 is available +today! This release brings over a year of features, improvements, and +refinements, resolving some of the most called for requests and bringing Rocket +measurably closer to stable compatibility. + +The release candidate is an opportunity to discover issues with Rocket v0.4 and +its documentation before its general release. We encourage all users to migrate +their applications to the release candidate and report any issues to the [GitHub +issue tracker]. + +[GitHub issue tracker]: https://github.com/SergioBenitez/Rocket/issues +""" + [[articles]] title = "Rocket v0.3: Fairings, TLS, Private Cookies" slug = "2017-07-14-version-0.3"