NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io · #2805 most downloaded on crates.io
Procedural macros for the Rocket web framework.
Last release 2 years ago
no release in 18 months
Release timing varies
gaps range from 2 weeks to 11 months
Nearly every release is documented
notes for 47 of 51 stable releases
1 version withdrawn
withdrawn after publishing
10 years old
58 releases · first in 2016
This release contains the following crate updates:
This release contains the following crate updates:
rocket 0.5.1rocket_db_pools 0.2.0rocket_dyn_templates 0.2.0rocket_ws 0.1.1See the CHANGELOG for release details.
This release contains the following crate updates:
rocket 0.5.1rocket_db_pools 0.2.0rocket_dyn_templates 0.2.0rocket_ws 0.1.1rocket 0.5.1The following char and std::ops::Range types now implement FromForm:
charRange<T: FromForm> with start and end fieldsRangeFrom<T: FromForm> with start fieldRangeTo<T: FromForm> with end fieldRangeToInclusive<T: FromForm> with end field[T; N], Vec<T>, and [u8] can now be passed to uri!.
The guide now includes a deploying section.
The FromForm derive now properly records errors involving entire forms.
FromForm derive can now be used in code emitted by macro_rules! macros.
(fix #2668 via 52de9a) [TempFile] now ensures it flushes before
being persisted.
rocket_db_pools 0.2.0SQLite extensions are now supported in sqlx_sqlite.
Use a database configuration option of extensions to specify extensions:
[default.databases.db_name]
url = "db.sqlite"
# This option is only supported by the `sqlx_sqlite` driver.
extensions = ["memvfs", "rot13"]
(breaking) deadpool was updated to 0.13.
(breaking) The Config
structure has a new extensions field.
rocket_dyn_templates 0.2.0Support for minijinja 2.0 templates was introduced.
Templates with an extension of .j2 are recognized and rendered with
Minijinja.
(breaking) handlebars was updated to 5.1.
rocket_ws 0.1.1Introduced WebSocket::accept_key() method.
tungstenite was updated to 0.21.
The rust-version for all crates was updated to 1.64.
This reflects the correct MSRV required to build rocket 0.5.0.
License files are now present in all published crates.
One column per quarter.
See the CHANGELOG , release news article , RWF2 announcement , migration guide , and FAQ for more information.
See the CHANGELOG, release news article, RWF2 announcement, migration guide, and FAQ for more information.
This release introduces the following major features and improvements:
async/await.rocket_ws.rocket_db_pools.Certificates.h2 ALPN.json, msgpack, and uuid rocket_contrib features into core.Shield: security and privacy headers for all responses.uri! macro.serde for built-in guards and types.#[launch] and
#[rocket::main].#[catch(default)], which handle any status code.TempFile data and form guard for automatic uploading to a temporary file.Capped<T> data and form guard which enables detecting truncation due to data limits.uri!.References.<param..>) which match zero segments.local_cache! macro for request-local storage of non-uniquely typed values.CookieJar without "one-at-a-time" limitations.2.mebibytes().#[derive(Responder)].chat application.As a result of support for Rust stable (Rust 2021 Edition and beyond),
#![feature(..)] crate attributes are no longer required to use Rocket. The
complete canonical example with a single hello route becomes:
#[macro_use] extern crate rocket;
#[get("/<name>/<age>")]
fn hello(name: &str, age: u8) -> String {
format!("Hello, {} year old named {}!", age, name)
}
#[launch]
fn rocket() -> _ {
rocket::build().mount("/hello", routes![hello])
}
<details> <summary>See a <code>diff</code> of the changes from v0.4.</summary>
- #![feature(proc_macro_hygiene, decl_macro)]
-
#[macro_use] extern crate rocket;
#[get("/<name>/<age>")]
- fn hello(name: String, age: u8) -> String {
+ fn hello(name: &str, age: u8) -> String {
format!("Hello, {} year old named {}!", age, name)
}
- fn main() {
- rocket::ignite().mount("/hello", routes![hello]).launch();
- }
+ #[launch]
+ fn rocket() -> _ {
+ rocket::build().mount("/hello", routes![hello])
+ }
</details>
This release includes many breaking changes. For a walkthrough guide on handling these changes, see the v0.4 to v0.5 migration guide. The most significant changes are listed below.
These changes are invisible to the compiler and will not yield errors or warnings at compile-time. We strongly advise all application authors to review this list carefully.
sleep(), Mutex, RwLock, etc.) may prevent
the server from making progress and should be avoided, replaced with an async variant, or
performed in a worker thread. This is a consequence of Rust's cooperative async multitasking.
For details, see the new multitasking section of the guide.ROCKET_ENV is now ROCKET_PROFILE. A warning is emitted a launch time if the former is set.debug, not dev.release, not prod.ROCKET_LOG is now ROCKET_LOG_LEVEL. A warning is emitted a launch time if the former is set.ROCKET_ADDRESS accepts only IP addresses, no longer resolves hostnames like localhost.ROCKET_CLI_COLORS accepts booleans true, false in place of strings "on", "off".secrets is enabled in non-debug profiles without a configured
secret_key.template_dir is reported as an error at launch time.FileServer::new() fails immediately if the provided directory does not exist.-12 to -1. There is no breaking change if only code generated
routes are used. Manually configured routes with negative ranks may collide or be considered in
a different order than before.: are properly recognized as invalid and rejected.Segments iterator now returns percent-decoded &strs.Form guard. Use Strict for the previous behavior.Option<T> form guard defaults to None instead of the default value for T.413 Payload Too Large status is returned to the client.Accept
header.true: the query string ?f is the same as ?f=true.Created<R> does not automatically send an ETag header if R: Hash. Use
Created::tagged_body instead.FileServer now forwards when a file is not found instead of failing with 404 Not Found.Shield is enabled by default. You may need to disable or change policies if your application
depends on typically insecure browser features or if you wish to opt-in to different policies
than the defaults.CookieJar get()s do not return cookies added during request handling. See
CookieJar#pending.Hash impls for MediaType and ContentType no longer consider media type parameters.FromForm implementations of Vec and Maps are now properly lenient.[ and ] characters are now accepted in URI paths.[ and ] characters are no longer encoded by uri!.Secure cookie flag is set by default for all cookies when serving over TLS.SameSite set to Lax by default.MediaType::JavaScript is now text/javascript.The rocket_contrib crate is deprecated and the functionality moved to other rocket crates. The
contrib deprecation upgrade guide provides a walkthrough on migrating. The relevant changes are:
rocket_contrib were merged into rocket itself:
json, msgpack, and uuid are now features of rocket.rocket_contrib::json to rocket::serde::json.rocket_contrib::msgpack to rocket::serde::msgpack.rocket_contrib::uuid to rocket::serde::uuid.rocket_contrib::helmet to rocket::shield. Shield is enabled by default.rocket_contrib::serve to rocket::fs, StaticFiles to rocket::fs::FileServer.Uuid and JsonValue wrapper types.Shield that are no longer respected by browsers.rocket_contrib are now provided by separate crates:
rocket_contrib::templates with rocket_dyn_templates.rocket_contrib::databases with rocket_sync_db_pools and rocket_db_pools.rocket.rocket_contrib::databases::DbError is now rocket_sync_db_pools::Error.redis, mongodb, and mysql integrations which have upstream async drivers.#[database]
attribute generates an async run() method instead of Deref implementations.The following breaking changes apply broadly and are likely to cause compile-time errors.
Rocket is now generic over a phase marker:
Rocket<Build>, Rocket<Ignite>, Rocket<Orbit>, or Rocket<P: Phase> as
needed.Build, Ignite, Orbit order.rocket::ignite() is now rocket::build() and returns a Rocket<Build>.Rocket::ignite() transitions to the Ignite phase. This is run automatically on launch as
needed.ignite fairings, and verifies sentinels.Rocket::launch() transitions into the Orbit phase and starts the server.Request::rocket() that refer to a live Rocket instance return an
&Rocket<Orbit>.async:
attach fairings with ignite fairings. Unlike attach fairings, which ran
immediately at the time of attachment, ignite fairings are run when transitioning into the
Ignite phase.launch fairings with liftoff fairings. liftoff fairings are always run, even in
local clients, after the server begins listening and the concrete port is known.ROCKET_ENV is superseded by ROCKET_PROFILE.ROCKET_LOG is superseded by ROCKET_LOG_LEVEL.dev, stage, and prod profiles carry no
special meaning.debug and release profiles are the default profiles for the debug and release
compilation profiles.default profile specifies defaults for all profiles.global profile has highest precedence, followed by the selected profile, followed by
default.LoggingLevel to LogLevel.Error structure.workers to usize from u16.keep_alive: it is disabled with 0, not false or off.secrets feature (for private cookies) by default.Figment.ConfigBuilder: all fields of Config are public with constructors for each field
type.async:
FromRequest, Fairing, catcher::Handler, route::Handler, and FromData use
#[async_trait].NamedFile::open is now an async function.Request::local_cache_async() for use in async request guards.Response bodies must be AsyncRead instead of Read.Response bodies must be AsyncSeek instead of Seek.local module is split into two: rocket::local::asynchronous and
rocket::local::blocking.Try implementation on Outcome which allowed using ? with Outcomes. The
recommended replacement is the rocket::outcome::try_outcome! macro or the various
combinator functions on Outcome.Result<T, E> implements Responder only when both T and E implement Responder. The
new Debug wrapping responder replaces Result<T: Responder, E: Debug>.! type to now use std::convert::Infallible.IntoOutcome was overhauled to supplant methods now removed in Outcome.
IntoOutcome::into_outcome() is now or_error().IntoOutcome is implemented for all Outcome type aliases.Outcome::forward() requires specifying a status code.Outcome::from() and Outcome::from_or_forward() were removed.Rocket::register() now takes a base path to scope catchers under as its first argument.ErrorKind::Collision has been renamed to ErrorKind::Collisions.tls feature is enabled.MediaType::with_params() and ContentType::with_params() are now builder methods.content responder type names are now prefixed with Raw.content::Plain responder is now called content::RawText.content::Custom<T> responder was removed in favor of (ContentType, T).CookieJar::get_private_pending() in favor of CookieJar::get_pending().local_cache! macro accepts fewer types. Use local_cache_once! as appropriate.Rocket::launch() allows Rocket recovery by returning the instance after shutdown.ErrorKind::Runtime was removed; ErrorKind::Shutdown was added.Outcome::Failure was renamed to Outcome::Error.#[route(GET, path = "...")], path is now uri: #[route(GET, uri = "...")]./<p..>) now match zero or more segments./<a>/<p..>) now collides with (/<a>), requires a rank to resolve.rocket::catcher.rocket::route.rocket::http::uri::fmt.T no longer converts to Option<T> or Result<T, _> for uri! query parameters.uri! requires using a wrapped value or _.&RawStr no longer implements FromParam: use &str instead.FromParam implementations.RawStr::url_decode() and RawStr::url_decode_lossy() allocate as necessary, return Cow.RawStr::from_str() was replaced with RawStr::new().Origin::segments() was replaced with Origin.path().segments().Origin::path() and Origin::query() return &RawStr instead of &str.Route::name is now Option<Cow<'static, str>>.Route::set_uri was replaced with Route::map_base().Route::uri field is now of type RouteUri.Route::base was removed in favor of Route.uri().base().Forward outcomes are now associated with a Status.FromParam errors now forward as 422.&Host, &Accept, &ContentType, IpAddr, and SocketAddr all forward
with a 500.Data now has a lifetime generic: Data<'r>.Data::open() indelibly requires a data limit.FromDataSimple. Use FromData and local_cache! or local_cache_once!.DataStream APIs require limits and return Capped<T> types.rocket::request to rocket::form.FromQuery. Dynamic query parameters (#[get("/?<param>")]) use FromForm instead.FromFormValue with FromFormField. All T: FromFormField implement FromForm.FromFormField implementations.#[form(field = ...)] attribute to #[field(name = ...)].Status.Cookies to CookieJar. Its methods take &self.Flash.name to Flash.kind, Flash.msg to Flash.message.Request::get_param() with Request::param().Request::get_segments() to Request::segments().Request::get_query_value() with Request::query_value().Segments::into_path_buf() with Segments::to_path_buf().Segments and QuerySegments with Segments<Path> and Segments<Query>.Flash constructors now take Into<String> instead of AsRef<str>.State<'_, T> request guard is now &State<T>.FromRequest: FromRequest<'r>.FlashMessage: FlashMessage<'_>.State reexports except rocket::State.NamedFile to rocket::fs::NamedFileContent with content::Custom.Response::body and Response::body_mut are now infallible methods.ResponseBuilder to Builder.Response body reading methods. Use methods on r.body_mut() instead.Responder impl for Response. Prefer custom responders with #[derive(Responder)].Status.response::status were unified to all be of
the form Status<R>(R).In addition to new features and changes, Rocket saw the following improvements:
FromForm derive, #[route] macros, and uri!.#[field(name = uncased(...))].#[field(default = expr())].#[field] attributes on struct fields.Config::ident for configuring or removing the global Server header.Rocket::figment() and Rocket::catchers().LocalRequest::json() and LocalResponse::json().LocalRequest::msgpack() and LocalResponse::msgpack().use m::route; routes![route] instead of needing routes![m::route].a/b/c falls back to a/b then a.LocalRequest::inner_mut(). LocalRequest implements DerefMut to Request.Config for all config parameter names.ErrorKind::Config to represent errors in configuration at runtime.rocket::fairing::Result type alias, returned by Fairing::on_ignite().Rocket::mount() now accepts a base value of any type that implements TryInto<Origin<'_>>.500 error catcher.Error to not panic if a panic is already in progress.Reference and Asterisk URI types.UriDisplayQuery for C-like enums.UriDisplayQuery derive now recognizes the #[field] attribute for field renaming.Client method builders accept TryInto<Origin> allowing a uri!() to be used directly.Rocket is now #[must_use].http2 crate feature.rocket::execute() for executing Rocket's launch() future.context! macro to rocket_dyn_templates for ad-hoc template contexts.time crate is re-exported from the crate root.FromForm, Responder, and UriDisplay derives now fully support generics.serde submodules.Shield HSTS preload header now includes includeSubdomains.write! errors if stdout disappears, preventing panics.Client::terminate() to run graceful shutdown in testing.async runtime, never the process.local_cache_once! macro for request-local storage.Rocket<Build> are now #[must_use], not all Rocket<P>.FromForm derive.FromForm derive now collects all errors that occur.rocket_sync_db_pools.Metadata::render() in rocket_dyn_templates for direct template rendering.cookie secure feature is now properly conditionally enabled.rocket_sync_db_pools was fixed.max_blocking configuration parameter to control number of blocking threads.ip_header "real IP" header configuration parameter.pool() method is emitted by rocket_sync_db_pools for code-generated pools.&[u8] form guard.TempFile::open() to stream TempFile data.LocalRequest::identity().Error::pretty_print() for pretty-printing errors like Rocket.String is used as a route parameter.debug log level.Outcomes now includes the relevant status code.Span::mixed_site() is used in codegen to reduce errant clippy warnings.http2 crate feature.const constructor for MediaType.RawStrBuf, an owned RawStr.RawStr.RawStr::percent_encode() and RawStr::strip().Host and &Host request guards.RawStr::percent_encode_bytes().NODELAY is now enabled on all connections by default.image/avif.EventStream: text/event-stream.Markdown: text/markdown.MP3: audio/mpeg.CBZ: application/vnd.comicbook+zip, extension .cbz.CBR: application/vnd.comicbook-rar, extension .cbr.RAR: application/vnd.rar, extension .rar.EPUB: application/epub+zip, extension .epub.OPF: application/oebps-package+xml, extension .opf.XHTML: application/xhtml+xml, extension .xhtml.Text as an alias for the Plain media type.Bytes as an alias for the Binary media type..mjs as known JavaScript extension.: in socket or IP address values in [FromFormValue].Request::rocket() to access the active Rocket instance.Request::uri() now returns an &Origin<'r> instead of &Origin<'_>.Request::accept(), Request::content_type() reflect changes to Accept, Content-Type.Json<T>, MsgPack<T> accept T: Deserialize, not only T: DeserializeOwned.rocket_sync_db_pools use better defaults.workers * 4.Request::host() to retrieve the client-requested host.Template::try_custom() for fallible template engine customization.Template::render().X-DNS-Prefetch-Control header to Shield.expires values for private cookies.#[derive(Responder)].Server header is only set if one isn't already set.Content-Length headers are sent even for partially read Bodys.Redirect now accepts a TryFrom<Reference>, allowing fragment parts.Clone for State.Copy and Clone for fairing::Info.Debug for Rocket and Client.Default for Status (returns Status::Ok).PartialEq, Eq, Hash, PartialOrd, and Ord for Status.Eq, Hash, and PartialEq<&str> for Origin.PartialEq<Cow<'_, RawStr>>> for RawStr.std::error::Error for Error.Deref and DerefMut for LocalRequest (to Request).DerefMut for Form, LenientForm.From<T> for Json<T>, MsgPack<T>.TryFrom<String> and TryFrom<&str> for Origin.TryFrom<Uri> for each of the specific URI variants.FromRequest for &Config.FromRequest for IpAddr.FromParam for PathBufFromParam, FromData, and FromForm for &str.FromForm for Json<T>, MsgPack<T>.FromFormField for Cow and Capped<Cow>>Responder for tokio::fs::File.Responder for (ContentType, R) where R: Responder.Responder for (Status, R) where R: Responder which overrides R's status.Responder for std::io::Error (behaves as Debug<std::io::Error>).Responder for Either<T, E>, equivalently to Result<T, E>.Serialize for Flash.Serialize, Deserialize, UriDisplay and FromUriParam for uuid::UuidSerialize, Deserialize for RawStr.Serialize, Deserialize for all URI types.Responder for Arc<T>, Box<T> where T: Responder.Serialize and Deserialize for Method.Eq for MediaType and ContentType.Responder for Box<T: Responder + Sized>.FromForm for Arc<T>.Fairing for Arc<dyn Fairing>.Serialize and Deserialize for Status.serde was introduced (1.0).futures was introduced (0.3).binascii was introduced (0.1).ref-cast was introduced (1.0).atomic was introduced (0.5).parking_lot was introduced (0.11).ubtye was introduced (0.10).figment was introduced (0.10).rand was introduced (0.8).either was introduced (1.0).pin-project-lite was introduced (0.2).indexmap was introduced (2.0).tempfile was introduced (3.0).async-trait was introduced (0.1).async-stream was introduced (0.3).multer was introduced (2.0).tokio was introduced (1.6.1).tokio-util was introduced (0.6).tokio-stream was introduced (0.1.6).bytes was introduced (1.0).normpath was introduced (1).state was updated to 0.6.rmp-serde was updated to 0.15.uuid was updated to 0.8.tera was updated to 1.10.postgres was updated to 0.19.rusqlite was updated to 0.25.r2d2_sqlite was updated to 0.18.time was updated to 0.3.handlebars was updated to 4.0.memcache was updated to 0.16.rustls was updated to 0.21.tokio-rustls was updated to 0.24.syn was updated to 2.diesel was updated to 2.0.sqlx was updated to 0.7.notify was updated to 6.criterion was updated to 0.4.cookie was updated to 0.18.yansi was updated to 1.0.atty was removed.The following changes were made to the project's infrastructure:
use statements to examples in the guide.criterion and datasets extracted from real-world projects.Cargo.toml files.test.sh for a + flag (e.g. +stable) to pass to cargo.test.sh for extra flags to be passed on to cargo.resolver = 2.See the CHANGELOG , news article , migration guide , and FAQ for more information.
See the CHANGELOG, news article, migration guide, and FAQ for more information.
See the CHANGELOG , news article , migration guide , and FAQ for more information.
See the CHANGELOG, news article, migration guide, and FAQ for more information.
See the CHANGELOG , news article , migration guide , and FAQ for more information.
See the CHANGELOG, news article, migration guide, and FAQ for more information.
See the CHANGELOG and news article for more information.
See the CHANGELOG and news article for more information.
See the CHANGELOG for more information.
See the CHANGELOG for more information.
See the CHANGELOG for more information.
See the CHANGELOG for more information.
3276b8] Removed unsafe in Origin::parse_owned(), fixing a soundness
issue.See the CHANGELOG for more information.
See the CHANGELOG for more information.
See the CHANGELOG for more information.
#1548, 93e88b0] Fixed an issue that prevented compilation under
Windows Subsystem for Linux v1.Outcome Try implementation to v2 in latest nightly.rustc is 1.54.0-nightly (2021-05-18).base64 dependency to 0.13.[[#1534], [2059a6]] Fixed a low-severity, minimal impact soundness issue in uri::Formatter.
[[86bd7c]] Added default and configurable read/write timeouts: read_timeout and write_timeout.
86bd7c] Added default and configurable read/write timeouts:
read_timeout and write_timeout.c24a96] Added the sse feature, which enables flushing by returning
io::ErrorKind::WouldBlock.contrib.contrib docs.trybuild instead of compiletest-rs.[[#1312], [89150f]] Fixed a low-severity, minimal impact soundness issue in LocalRequest::clone().
89150f] Fixed a low-severity, minimal impact soundness issue in
LocalRequest::clone().376f74] Fixed a cookie serialization issue that led to
incorrect cookie deserialization in certain cases.ring for private cookies and thus Rocket, by
default.Origin::map_path() for manipulating Origin paths.handler::Outcome::from_or_forward().Options::NormalizeDirs option to StaticFiles.Removed use of unsupported cfg(debug_assertions) in Cargo.toml, allowing for builds on latest nightlies.
cfg(debug_assertions) in Cargo.toml, allowing
for builds on latest nightlies.Specialization on Result was deprecated. [Debug] can be used in place of non-Responder errors.
Debug 500 Responder that Debug-prints its contents on
response.Result was deprecated. Debug can be used in place of
non-Responder errors.Debug implementations on Rocket types now respect formatting
options.Responders for various HTTP status codes: NoContent,
Unauthorized, Forbidden, and Conflict.FromParam is implemented for NonZero core types.Some, Ok, and
Err are shadowed.core crate; rocket_codegen makes no
appearances.Replaced use of FnBox with Box .
FnBox with Box<dyn FnOnce>.try_from and transpose_result.rustc is 1.35.0-nightly (2019-04-05).JsonValue now implements FromIterator.non_snake_case errors are silenced in generated code.rustc is 1.33.0-nightly (2019-01-03).StaticFiles via StaticFiles::rank().MsgPack correctly sets a MessagePack Content-Type on responses.Removed deprecated isatty dependency in favor of atty.
Server HTTP header no longer overrides a user-set header.DerefMut.isatty dependency in favor of atty.This release includes many breaking changes. These changes are listed below along with a short note about how to handle the breaking change in existin…
This release includes the following new features:
StaticFiles.Handler.FromData::transform().SpaceHelmet security and privacy headers fairing.private-cookies default feature.FromFormValue.Responder.Template::custom() for customizing templating engines including
registering filters and helpers.Client.LocalRequest::private_cookie().production environment.keep_alive configuration parameter.ROCKET_CLI_COLORS=off.format accepts shorthands such as json and html.Responder for Status.Response::cookies() for retrieving response cookies.log is set to off.Metadata guard for retrieving templating information.Uri type parses URIs according to RFC 7230 into one of Origin,
Absolute, or Authority.Outcome::and_then(), Outcome::failure_then(), and
Outcome::forward_then().Responder for &[u8].T: Into<Vec<Route>> can be mount()ed.Request::get_query_value() for retrieving a query value by key.State::from() for constructing State values.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:
- #![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:
[dependencies]
- rocket = "0.3"
+ rocket = "0.4"
- rocket_codegen = "0.3"
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.
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.
Query handling syntax has been completely revamped.
A query parameter of <param> is now <param..>. Consider whether your
application benefits from the revamped query string handling.
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.
json! returns a JsonValue, no longer needs wrapping.
Change instances of Json(json!(..)) to json! and change the
corresponding type to JsonValue.
All environments default to port 8000.
Manually configure a port of 80 for the stage and production
environments for the previous behavior.
Release builds default to the production environment.
Manually set the environment to debug with ROCKET_ENV=debug for the
previous behavior.
Form and LenientForm lost a lifetime parameter, get() method.
Change a type of Form<'a, T<'a>> to Form<T> or Form<T<'a>>. Form<T>
and LenientForm<T> now implement Deref<Target = T>, allowing for calls
to .get() to be removed.
ring was updated to 0.13.
Ensure all transitive dependencies to ring refer to version 0.13.
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.
All items in rocket_contrib are namespaced behind modules.
Json is now json::JsonMsgPack is now msgpack::MsgPackMsgPackError is now msgpack::ErrorTemplate is now templates::TemplateUUID is now uuid::UuidValue is replaced by json::JsonValueTLS 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.
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.
LocalRequest::cloned_dispatch() was removed.
Chain calls to .clone().dispatch() for the previous behavior.
Redirect constructors take a generic type of T: TryInto<Uri<'static>>.
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.
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.
FormItems iterates over values of type FormItem.
Map using .map(|item| item.key_value()) for the previous behavior.
LaunchErrorKind::Collision contains a vector of the colliding routes.
Destruct using LaunchErrorKind::Collision(..) to ignore the vector.
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.
Config::root() returns an Option<&Path> instead of an &Path.
For the previous behavior, use config.root().unwrap().
Status::new() is no longer const.
Construct a Status directly.
Config constructors return a Config instead of a Result<Config>.
ConfigError::BadCWD, Config.config_path were removed.
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.
In addition to new features, Rocket saw the following improvements:
403 catcher now references authorization, not authentication.HttpOnly and are given an expiration date of 1
week by default.rocket_codegen.400 instead of 500.HEAD requests.504: Gateway Timeout.unsafe was reduced from 9 to 2 in core library.FormItems now parses empty keys and values as well as keys without
values.Config::active() as a shorthand for
Config::new(Environment::active()?).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.Config::root_relative() for retrieving paths relative to the
configuration file.Config::tls_enabled() for determining whether TLS is actively
enabled.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), ZIP (application/zip) as known
media types..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.println!.Form and LenientForm can be publicly constructed.i128 and u128 now implement FromParam, FromFormValue.base64 dependency was updated to 0.10.log dependency was updated to 0.4.handlebars dependency was updated to 1.0.tera dependency was updated to 0.11.uuid dependency was updated to 0.7.rustls dependency was updated to 0.14.cookie dependency was updated to 0.11.core and
contrib.http module was split into its own rocket_http crate. This is an
internal change only.unsafe are documented with informal proofs of correctness.Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Codegen was updated for 2018-08-23 nightly.
2018-08-23 nightly.rustc is 1.30.0-nightly 2018-08-23.The #[error] decorator and errors! macro were deprecated.
#[catch] decorator and catchers! macro were introduced, replacing
#[error] and errors!.#[error] decorator and errors! macro were deprecated.2018-07-15 nightly.rustc is 1.29.0-nightly 2018-07-15.Codegen was updated for 2018-06-22 nightly.
2018-06-22 nightly.rustc is 1.28.0-nightly 2018-06-22.Codegen was updated for 2018-06-12 nightly.
2018-06-12 nightly.rustc is 1.28.0-nightly 2018-06-12.Codegen was updated for 2018-05-30 nightly.
2018-05-30 nightly.rustc is 1.28.0-nightly 2018-05-30.Core was updated for 2018-05-18 nightly.
2018-05-18 nightly.Fixed parsing of nested TOML structures in config environment variables.
2018-05-03 nightly.rustc is 1.27.0-nightly 2018-05-04.2018-05-03 nightly.Core was updated for 2018-04-26 nightly.
2018-04-26 nightly.rustc is 1.27.0-nightly 2018-04-26.HashMap
lookup.2018-04-26 nightly.rustc is 1.27.0-nightly 2018-04-26.Codegen was updated for 2018-04-06 nightly.
2018-04-06 nightly.rustc is 1.27.0-nightly 2018-04-06.Fixed a bug where incoming request URIs would match routes with the same path prefix and suffix and ignore the rest.
2018-04-03 nightly.rustc is 1.27.0-nightly 2018-04-03.iterator_for_each, i128_type,
conservative_impl_trait, never_type.Rocket.state() method was added to retrieve managed state from Rocket instances.
Rocket.state() method was added to retrieve managed state from Rocket
instances.Rocket.attach() are now handled correctly.application/vnd.api+json) is now a known media type.ContentType and Accept headers are properly
preserved on Request.clone().rustc is 1.25.0-nightly 2018-01-12.2017-12-22 nightly.rustc is 1.24.0-nightly 2017-12-22.git grep instead of egrep for faster searching.Codegen was updated for 2017-12-17 nightly.
2017-12-17 nightly.rustc is 1.24.0-nightly 2017-12-17.NamedFile's Responder implementation now uses a sized body when the file's length is known.
NamedFile's Responder implementation now uses a sized body when the
file's length is known.#[repr(C)] is used on str wrappers to guarantee correct structure layout
across platforms.status::BadRequest Responder was added.2017-12-13 nightly.rustc is 1.24.0-nightly 2017-12-13.html_root_url now points to the correct address.Outcome docs: Config's Debug implementation now respects formatting options.
Config's Debug implementation now respects formatting options.Cow<str> now implements FromParam.Vec<u8> now implements Responder.Binary media type for application/octet-stream.rustc is 1.22.0-nightly 2017-09-13.2017-09-25 nightly.rustc is 1.22.0-nightly 2017-09-25.ReponderResponder.Added conversion methods from and to Box .
Box<UncasedStr>.rocket_lints crate.Added support for ASCII colors on modern Windows consoles.
_ident).assert! to fail
(#367).2017-08-10 nightly.rustc is 1.21.0-nightly (2017-08-10).This release includes many breaking changes. These changes are listed below along with a short note about how to handle the breaking change in existin…
This release includes the following new features:
MsgPack type has been added to contrib for simple consumption and
returning of MessagePack data.LaunchError) from Rocket::launch() are now returned
for inspection without panicking.Accept header structure was added.Accept request header can be retrieved via Request::accept().#[form(field = "name")]
structure field attribute.Rocket::routes().Response::body_string() was added to retrieve the response body as a
String.Response::body_bytes() was added to retrieve the response body as a
Vec<u8>.Response::content_type() was added to easily retrieve the Content-Type
header of a response.Request::limits() was added to retrieve incoming data limits.Request::guard() was added for simple retrieval of request guards.Request::route() was added to retrieve the active route, if any.&Route is now a request guard.Route can be retrieved via Route::base or
Route::base().Cookies supports private (authenticated encryption) cookies, encrypted
with the secret_key config key.Config::{development, staging, production} constructors were added for
Config.Config::get_datetime() was added to retrieve an extra as a Datetime.LenientForm data guard.? operator can now be used with Outcome.stdout is not a TTY.FromForm is implemented for Option<T: FromForm>, Result<T: FromForm, T::Error>.NotFound responder was added for simple 404 response
construction.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.
session_key was renamed to secret_key, requires a 256-bit base64 key
It's unlikely that session_key was previously used. If it was, rename
session_key to secret_key. Generate a random 256-bit base64 key using a
tool like openssl: openssl rand -base64 32.
The &Cookies request guard has been removed in favor of Cookies
Change &Cookies in a request guard position to Cookies.
Rocket::launch() now returns a LaunchError, doesn't panic.
For the old behavior, suffix a call to .launch() with a semicolon:
.launch();.
Routes without query parameters match requests with or without query parameters.
There is no workaround, but this change may allow manual ranks from routes to be removed.
The format route attribute on non-payload requests matches against the
Accept header.
Excepting a custom request guard, there is no workaround. Previously,
format always matched against the Content-Type header, regardless of
whether the request method indicated a payload or not.
A type of &str can no longer be used in form structures or parameters.
Use the new &RawStr type instead.
ContentType is no longer a request guard.
Use &ContentType instead.
Request::content_type() returns &ContentType instead of
ContentType.
Use .clone() on &ContentType if a type of ContentType is required.
Response::header_values() was removed. Response::headers() now returns
an &HeaderMap.
A call to Response::headers() can be replaced with
Response::headers().iter(). A call to Response::header_values(name) can
be replaced with Response::headers().get(name).
Route collisions result in a hard error and panic.
There is no workaround. Previously, route collisions were a warning.
The IntoOutcome trait has been expanded and made more flexible.
There is no workaround. IntoOutcome::into_outcome() now takes a Failure
value to use. IntoOutcome::or_forward() was added to return a Forward
outcome if self indicates an error.
The 'testing' feature was removed.
Remove features = ["testing"] from Cargo.toml. Use the new local
module for testing.
serde was updated to 1.0.
There is no workaround. Ensure all dependencies rely on serde 1.0.
config::active() was removed.
Use Rocket::config() to retrieve the configuration before launch. If
needed, use managed state to store config information for later use.
The Responder trait has changed.
Responder::respond(self) was removed in favor of
Responder::respond_to(self, &Request). Responders may dynamically adjust
their response based on the incoming request.
Outcome::of(Responder) was removed while Outcome::from(&Request, Responder) was added.
Use Outcome::from(..) instead of Outcome::of(..).
Usage of templates requires Template::fairing() to be attached.
Call .attach(Template::fairing()) on the application's Rocket instance
before launching.
The Display implementation of Template was removed.
Use Template::show() to render a template directly.
Request::new() is no longer exported.
There is no workaround.
The FromForm trait has changed.
Responder::from_form_items(&mut FormItems) was removed in favor of
Responder::from_form(&mut FormItems, bool). The second parameter indicates
whether parsing should be strict (if true) or lenient (if false).
LoggingLevel was removed as a root reexport.
It can now be imported from rocket::config::LoggingLevel.
An Io variant was added to ConfigError.
Ensure matches on ConfigError include an Io variant.
ContentType::from_extension() returns an Option<ContentType>.
For the old behavior, use .unwrap_or(ContentType::Any).
The IntoValue config trait was removed in favor of Into<Value>.
There is no workaround. Use Into<Value> as necessary.
The rocket_contrib::JSON type has been renamed to
rocket_contrib::Json.
Use Json instead of JSON.
All structs in the content module use TitleCase names.
Use Json, Xml, Html, and Css instead of JSON, XML, HTML, and
CSS, respectively.
In addition to new features, Rocket saw the following improvements:
Server HTTP header.rocket_contrib::Json defaults to json::Value.FromData is implemented for Vec<u8> and String.uuid dependency was updated to 0.5.base64 dependency was updated to 0.6.toml dependency was updated to 0.4.handlebars dependency was updated to 0.27.tera dependency was updated to 0.10.yansi is now used for all terminal coloring.dev rustc release channel is supported during builds.Config is now exported from the root.Request implements Clone and Debug.workers config parameter now defaults to num_cpus * 2.PartialOrd, Ord, and Hash are now implemented for State.format now functions as documented.master branch now uses a -dev version number.Nothing published for this version
Nothing published for this version
Nothing published for this version
Lints were updated for 2017-06-01 nightly.
2017-06-01 nightly.rustc is 1.19.0-nightly (2017-06-01).Codegen was updated for 2017-05-26 nightly.
2017-05-26 nightly.Allow k and v to be used as fields in FromForm structures by avoiding identifier collisions ([#265]).
k and v to be used as fields in FromForm structures by avoiding
identifier collisions (#265).Lints were updated for 2017-04-15 nightly.
2017-04-15 nightly.rustc is 1.18.0-nightly (2017-04-15).Codegen was updated for 2017-03-30 nightly.
2017-03-30 nightly.rustc is 1.18.0-nightly (2017-03-30).Multiple header values for the same header name are now properly preserved (#223).
get_slice and get_table methods were added to Config.pub_restricted feature has been stabilized!2017-03-20 nightly.rustc is 1.17.0-nightly (2017-03-22).Lints were updated for 2017-02-25 and 2017-02-26 nightlies.
2017-02-25 and 2017-02-26 nightlies.rustc is 1.17.0-nightly (2017-02-26).Flash cookie deletion functions as expected regardless of the path.
Flash cookie deletion functions as expected regardless of the path.config properly accepts IPv6 addresses.Set-Cookie headers are properly set.Display and Error were implemented for ConfigError.webp, ttf, otf, woff, and woff2 were added as known content types.into_bytes and into_inner methods were added to Body.unmanaged_state lint so that it works with prefilled type aliases.manage and JSON docs.This release includes several breaking changes. These changes are listed below along with a short note about how to handle the breaking change in exis…
Detailed release notes for v0.2 can also be found on rocket.rs.
This release includes the following new features:
Config structures can be built via ConfigBuilder, which follows the
builder pattern.Rocket::custom method.name and value methods were added to Header to retrieve the name and
value of a header.workers, can be used to set the number of
threads Rocket uses.Request.remote().
Request preprocessing overrides remote IP with value from the X-Real-IP
header, if present.MockRequest.remote().SocketAddr request guard retrieves the remote address.UUID type has been added to contrib.rocket and rocket_codegen will refuse to build with an incompatible
nightly version and emit nice error messages.cookie
crate, including the addition of a CookieBuilder.bool types in a FromForm
structure will parse as false.FormItems iterator can be queried for a complete parse via completed
and exhausted.OPTIONS requests can be declared via the options decorator.URI::percent_encode().This release includes several breaking changes. These changes are listed below along with a short note about how to handle the breaking change in existing applications.
Rocket::custom takes two parameters, the first being Config by
value.
A call in v0.1 of the form Rocket::custom(&config) is now
Rocket::custom(config, false).
Tera templates are named without their extension.
A templated named name.html.tera is now simply name.
JSON unwrap method has been renamed to into_inner.
A call to .unwrap() should be changed to .into_inner().
The map! macro was removed in favor of the json! macro.
A call of the form map!{ "a" => b } can be written as: json!({ "a": b }).
The hyper::SetCookie header is no longer exported.
Use the Cookie type as an Into<Header> type directly.
The Content-Type for String is now text/plain.
Use content::HTML<String> for HTML-based String responses.
Request.content_type() returns an Option<ContentType>.
Use .unwrap_or(ContentType::Any) to get the old behavior.
The ContentType request guard forwards when the request has no
Content-Type header.
Use an Option<ContentType> and .unwrap_or(ContentType::Any) for the old
behavior.
A Rocket instance must be declared before a MockRequest.
Change the order of the rocket::ignite() and MockRequest::new() calls.
A route with format specified only matches requests with the same
format.
Previously, a route with a format would match requests without a format
specified. There is no workaround to this change; simply specify formats
when required.
FormItems can no longer be constructed directly.
Instead of constructing as FormItems(string), construct as
FormItems::from(string).
from_from_string(&str) in FromForm removed in favor of
from_form_items(&mut FormItems).
Most implementation should be using FormItems internally; simply use the
passed in FormItems. In other cases, the form string can be retrieved via
the inner_str method of FormItems.
Config::{set, default_for} are deprecated.
Use the set_{param} methods instead of set, and new or build in
place of default_for.
Route paths must be absolute.
Prepend a / to convert a relative path into an absolute one.
Route paths cannot contain empty segments.
Remove any empty segments, including trailing ones, from a route path.
A couple of bugs were fixed in this release:
Rocket::custom did not set the custom configuration as the active
configuration.In addition to new features, Rocket saw the following smaller improvements:
port Config type is now a proper u16.0.25.PartialEq implementation of Config doesn't consider the path or
secret key.0.10.Error type for JSON as FromData has been exposed as SerdeError.0.9.0.7.pub(crate) is used throughout to enforce visibility rules./path?<param>) are now logged.Hyper version pinned to 0.9.14 due to upstream non-semver breaking change.
Fixed security checks in FromSegments implementation for PathBuf.
FromSegments implementation for PathBuf.proc_macro feature removed from examples due to stability.Header names are treated as case-preserving.
2017-01-03.Deriving FromForm no longer results in a deprecation warning.
Outcome formatting fixed (Succcess -> Success).ContentType::CSV._method field on POST.Strings are properly decoded._method field is now properly ignored in FromForm derivation.format no longer result in an error.FromForm no longer results in a deprecation warning.head as a valid decorator for HEAD requests.route(OPTIONS) as a valid decorator for OPTIONS requests..tera extension are properly autoescaped.Display.README.config, optional_result, optional_redirect, and
query_params examples.bump_version.sh) automates version bumps.Fix get_raw_segments index argument in route codegen (#41).
NamedFile Responder lost its body in the shuffle; it's back!
NamedFile Responder lost its body in the shuffle; it's back!This is the first public release of Rocket!
This is the first public release of Rocket!
All of the mentions to hyper types in core Rocket types are no more. Rocket
now implements its own Request and Response types.
ContentType uses associated constants instead of static methods.StatusCode removed in favor of new Status type.Response type alias superseded by Response type.Responder::respond no longer takes in hyper type.Responder::respond returns Response, takes self by move.Handler returns Outcome instead of Response type alias.ErrorHandler returns Result.Hyper* types were moved to unprefixed versions in hyper::.MockRequest::dispatch now returns a Response type.URIBuf removed in favor of unified URI.HEAD requests automatically.Response and ResponseBuilder types.Request, Header, Status, and ContentType types.MockRequest allows any type of header.MockRequest allows cookies.ROCKET_CODEGEN_DEBUG environment variables enables codegen logging.Your coding agent can read these notes before it upgrades. Set up the MCP server →