- Rocket's default
Server
HTTP header no longer overrides a user-set header. - Fixed encoding and decoding of certain URI characters.
- Compiler diagnostic information is more reliably produced.
- Database pool types now implement
DerefMut
. - Added support for memcache connection pools.
- Stopped depending on default features from core.
- Fixed many typos across the rustdocs and guide.
- Added guide documentation on mounting more than one route at once.
- Testing no longer requires "bootstrapping".
- Removed deprecated
isatty
dependency in favor ofatty
.
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.
- Introduced the
SpaceHelmet
security and privacy headers fairing. - Private cookies are gated behind a
private-cookies
default feature. - 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 asjson
andhtml
. - Implemented
Responder
forStatus
. - Added
Response::cookies()
for retrieving response cookies. - All logging is disabled when
log
is set tooff
. - Added
Metadata
guard for retrieving templating information. - The
Uri
type parses URIs according to RFC 7230 into one ofOrigin
,Absolute
, orAuthority
. - Added
Outcome::and_then()
,Outcome::failure_then()
, andOutcome::forward_then()
. - Implemented
Responder
for&[u8]
. - Any
T: Into<Vec<Route>>
can bemount()
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. - Applications can launch without a working directory.
- Added
State::from()
for constructingState
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
orcrate
. -
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 anderrors!
macro were removed.Use
#[catch]
andcatchers!
instead. -
Rocket::catch()
was renamed toRocket::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 aJsonValue
, no longer needs wrapping.Change instances of
Json(json!(..))
tojson!
and change the corresponding type toJsonValue
. -
All environments default to port 8000.
Manually configure a port of
80
for thestage
andproduction
environments for the previous behavior. -
Release builds default to the production environment.
Manually set the environment to
debug
withROCKET_ENV=debug
for the previous behavior. -
Form
andLenientForm
lost a lifetime parameter,get()
method.Change a type of
Form<'a, T<'a>>
toForm<T>
orForm<T<'a>>
.Form<T>
andLenientForm<T>
now implementDeref<Target = T>
, allowing for calls to.get()
to be removed. -
ring
was updated to 0.13.Ensure all transitive dependencies to
ring
refer to version0.13
. -
Uri
was largely replaced byOrigin
.In general, replace the type
Uri
withOrigin
. Thebase
anduri
fields ofRoute
are now of typeOrigin
. The&Uri
guard is now&Origin
.Request::uri()
now returns anOrigin
. -
All items in
rocket_contrib
are namespaced behind modules.Json
is nowjson::Json
MsgPack
is nowmsgpack::MsgPack
MsgPackError
is nowmsgpack::Error
Template
is nowtemplates::Template
UUID
is nowuuid::Uuid
Value
is replaced byjson::JsonValue
-
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 aroot
.Use
client.rocket()
to get a reference to an instance ofRocket
when testing. UseTemplate::render()
in routes. -
Request::remote()
returns the actual remote IP, doesn't rewrite.Use
Request::real_ip()
orRequest::client_ip()
to retrieve the IP address from the "X-Real-IP" header if it is present. -
Bind
variant was added toLaunchErrorKind
.Ensure matches on
LaunchErrorKind
include or ignore theBind
variant. -
Cookies are automatically tracked and propagated by
Client
.For the previous behavior, construct a
Client
withClient::untracked()
. -
UUID
was renamed toUuid
.Use
Uuid
instead ofUUID
. -
LocalRequest::cloned_dispatch()
was removed.Chain calls to
.clone().dispatch()
for the previous behavior. -
Redirect
constructors take a generic type ofT: TryInto<Uri<'static>>
.A call to a
Redirect
constructor with a non-'static
&str
of the formRedirect::to(string)
should becomeRedirect::to(string.to_string())
, heap-allocating the string before being passed to the constructor. -
The
FromData
impl forForm
andLenientForm
now return an error of typeFormDataError
.On non-I/O errors, the form string is stored in the variant as an
&'f str
. -
Missing
variant was added toConfigError
.Ensure matches on
ConfigError
include or ignore theMissing
variant. -
The
FromData
impl forJson
now returns an error of typeJsonError
.The previous
SerdeError
is now the.1
member of theJsonError
enum
. Match and destruct the variant for the previous behavior. -
FromData
is now emulated byFromDataSimple
.Change implementations, not uses, of
FromData
toFromDataSimple
. Consider whether your implementation could benefit from transformations. -
FormItems
iterates over values of typeFormItem
.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()
andRequest::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
andMsgPack
data guards no longer reject requests with an unexpected Content-TypeTo approximate the previous behavior, add a
format = "json"
route parameter when usingJson
orformat = "msgpack"
when usingMsgPack
. -
Implemented
Responder
forStatus
. RemovedFailure
,status::NoContent
, andstatus::Reset
responders.Replace uses of
Failure(status)
withstatus
directly. Replacestatus::NoContent
withStatus::NoContent
. Replacestatus::Reset
withStatus::ResetContent
. -
Config::root()
returns anOption<&Path>
instead of an&Path
.For the previous behavior, use
config.root().unwrap()
. -
Status::new()
is no longerconst
.Construct a
Status
directly. -
Config
constructors return aConfig
instead of aResult<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 ofForm
andLenientForm
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:
- 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.
- All macros, derives, and attributes are individually documented in
rocket_codegen
. - Invalid client requests receive a response of
400
instead of500
. - 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 forConfig::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 onAdHoc::on_attach()
,AdHoc::on_launch()
was removed.AdHoc::on_attach()
,AdHoc::on_launch()
accept anFnOnce
.- 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
), ZIP (application/zip
) 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.
Form
andLenientForm
can be publicly constructed.- Console coloring uses default terminal colors instead of white.
- Console coloring is consistent across all messages.
i128
andu128
now implementFromParam
,FromFormValue
.- The
base64
dependency was updated to0.10
. - The
log
dependency was updated to0.4
. - The
handlebars
dependency was updated to1.0
. - The
tera
dependency was updated to0.11
. - The
uuid
dependency was updated to0.7
. - The
rustls
dependency was updated to0.14
. - The
cookie
dependency was updated to0.11
.
- All documentation is versioned.
- Previous, current, and development versions of all documentation are hosted.
- The repository was reorganized with top-level directories of
core
andcontrib
. - The
http
module was split into its ownrocket_http
crate. This is an internal change only. - All uses of
unsafe
are documented with informal proofs of correctness.
- Codegen was updated for
2018-08-23
nightly. - Minimum required
rustc
is1.30.0-nightly 2018-08-23
.
- Force close only the read end of connections. This allows responses to be sent even when the client transmits more data than expected.
- Add details on retrieving configuration extras to guide.
- The
#[catch]
decorator andcatchers!
macro were introduced, replacing#[error]
anderrors!
. - The
#[error]
decorator anderrors!
macro were deprecated. - Codegen was updated for
2018-07-15
nightly. - Minimum required
rustc
is1.29.0-nightly 2018-07-15
.
- Codegen was updated for
2018-06-22
nightly. - Minimum required
rustc
is1.28.0-nightly 2018-06-22
.
- Codegen was updated for
2018-06-12
nightly. - Minimum required
rustc
is1.28.0-nightly 2018-06-12
.
- Codegen was updated for
2018-05-30
nightly. - Minimum required
rustc
is1.28.0-nightly 2018-05-30
.
- Core was updated for
2018-05-18
nightly.
- Fixed injection of dependencies for codegen compile-fail tests.
- Fixed parsing of nested TOML structures in config environment variables.
- Codegen was updated for
2018-05-03
nightly. - Minimum required
rustc
is1.27.0-nightly 2018-05-04
.
- Contrib was updated for
2018-05-03
nightly.
- Fixed database pool type in state guide.
- Core was updated for
2018-04-26
nightly. - Minimum required
rustc
is1.27.0-nightly 2018-04-26
. - Managed state retrieval cost was reduced to an unsynchronized
HashMap
lookup.
- Codegen was updated for
2018-04-26
nightly. - Minimum required
rustc
is1.27.0-nightly 2018-04-26
.
- A 512-byte buffer is preallocated when deserializing JSON, improving performance.
- Fixed various typos in rustdocs and guide.
- Codegen was updated for
2018-04-06
nightly. - Minimum required
rustc
is1.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.
- Added known media types for WASM, WEBM, OGG, and WAV.
- Fixed fragment URI parsing.
- Codegen was updated for
2018-04-03
nightly. - Minimum required
rustc
is1.27.0-nightly 2018-04-03
.
- JSON data is read eagerly, improving deserialization performance.
- Database example and docs were updated for Diesel 1.1.
- Removed outdated README performance section.
- Fixed various typos in rustdocs and guide.
- Removed gates for stabilized features:
iterator_for_each
,i128_type
,conservative_impl_trait
,never_type
. - Travis now tests in both debug and release mode.
Rocket.state()
method was added to retrieve managed state fromRocket
instances.- Nested calls to
Rocket.attach()
are now handled correctly. - JSON API (
application/vnd.api+json
) is now a known media type. - Uncached markers for
ContentType
andAccept
headers are properly preserved onRequest.clone()
. - Minimum required
rustc
is1.25.0-nightly 2018-01-12
.
- Codegen was updated for
2017-12-22
nightly. - Minimum required
rustc
is1.24.0-nightly 2017-12-22
.
- Fixed typo in state guide:
simplesimply. - Database example and docs were updated for Diesel 1.0.
- Shell scripts now use
git grep
instead ofegrep
for faster searching.
- Codegen was updated for
2017-12-17
nightly. - Minimum required
rustc
is1.24.0-nightly 2017-12-17
.
NamedFile
'sResponder
implementation now uses a sized body when the file's length is known.#[repr(C)]
is used onstr
wrappers to guarantee correct structure layout across platforms.- A
status::BadRequest
Responder
was added.
- Codegen was updated for
2017-12-13
nightly. - Minimum required
rustc
is1.24.0-nightly 2017-12-13
.
- The rustdoc
html_root_url
now points to the correct address. - Fixed typo in fairings guide:
eventevents. - Fixed typo in
Outcome
docs:usersUsers.
Config
'sDebug
implementation now respects formatting options.Cow<str>
now implementsFromParam
.Vec<u8>
now implementsResponder
.- Added a
Binary
media type forapplication/octet-stream
. - Empty fairing collections are no longer logged.
- Emojis are no longer emitted to non-terminals.
- Minimum required
rustc
is1.22.0-nightly 2017-09-13
.
- Improved "missing argument in handler" compile-time error message.
- Codegen was updated for
2017-09-25
nightly. - Minimum required
rustc
is1.22.0-nightly 2017-09-25
.
- Fixed typos in site overview:
bybe,Reponder
Responder
. - Markdown indenting was adjusted for CommonMark.
- Shell scripts handle paths with spaces.
- Added conversion methods from and to
Box<UncasedStr>
.
- Lints were removed due to compiler instability. Lints will likely return as
a separate
rocket_lints
crate.
- Added support for ASCII colors on modern Windows consoles.
- Form field renames can now include any valid characters, not just idents.
- Ignored named route parameters are now allowed (
_ident
). - Fixed issue where certain paths would cause a lint
assert!
to fail (#367). - Lints were updated for
2017-08-10
nightly. - Minimum required
rustc
is1.21.0-nightly (2017-08-10)
.
- Tera errors that were previously skipped internally are now emitted.
- Typos were fixed across the board.
This release includes the following new features:
- Fairings, Rocket's structure middleware, were introduced.
- Native TLS support was introduced.
- Private cookies were introduced.
- A
MsgPack
type has been added tocontrib
for simple consumption and returning of MessagePack data. - Launch failures (
LaunchError
) fromRocket::launch()
are now returned for inspection without panicking. - Routes without query parameters now match requests with or without query parameters.
- Default rankings range from -4 to -1, preferring static paths and routes with query string matches.
- A native
Accept
header structure was added. - The
Accept
request header can be retrieved viaRequest::accept()
. - Incoming form fields can be renamed via a new
#[form(field = "name")]
structure field attribute. - All active routes can be retrieved via
Rocket::routes()
. Response::body_string()
was added to retrieve the response body as aString
.Response::body_bytes()
was added to retrieve the response body as aVec<u8>
.Response::content_type()
was added to easily retrieve the Content-Type header of a response.- Size limits on incoming data are now configurable.
Request::limits()
was added to retrieve incoming data limits.- Responders may dynamically adjust their response based on the incoming request.
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.- The base mount path of a
Route
can be retrieved viaRoute::base
orRoute::base()
. Cookies
supports private (authenticated encryption) cookies, encryped with thesecret_key
config key.Config::{development, staging, production}
constructors were added forConfig
.Config::get_datetime()
was added to retrieve an extra as aDatetime
.- Forms can be now parsed leniently via the new
LenientForm
data guard. - The
?
operator can now be used withOutcome
. - Quoted string, array, and table based configuration parameters can be set via environment variables.
- Log coloring is disabled when
stdout
is not a TTY. FromForm
is implemented forOption<T: FromForm>
,Result<T: FromForm, T::Error>
.- The
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 tosecret_key
, requires a 256-bit base64 keyIt's unlikely that
session_key
was previously used. If it was, renamesession_key
tosecret_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 ofCookies
Change
&Cookies
in a request guard position toCookies
. -
Rocket::launch()
now returns aLaunchError
, 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 ofContentType
.Use
.clone()
on&ContentType
if a type ofContentType
is required. -
Response::header_values()
was removed.Response::headers()
now returns an&HeaderMap
.A call to
Response::headers()
can be replaced withResponse::headers().iter()
. A call toResponse::header_values(name)
can be replaced withResponse::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 aFailure
value to use.IntoOutcome::or_forward()
was added to return aForward
outcome ifself
indicates an error. -
The 'testing' feature was removed.
Remove
features = ["testing"]
fromCargo.toml
. Use the newlocal
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 ofResponder::respond_to(self, &Request)
. Responders may dynamically adjust their response based on the incoming request. -
Outcome::of(Responder)
was removed whileOutcome::from(&Request, Responder)
was added.Use
Outcome::from(..)
instead ofOutcome::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 ofTemplate
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 ofResponder::from_form(&mut FormItems, bool)
. The second parameter indicates whether parsing should be strict (iftrue
) or lenient (iffalse
). -
LoggingLevel
was removed as a root reexport.It can now be imported from
rocket::config::LoggingLevel
. -
An
Io
variant was added toConfigError
.Ensure
match
es onConfigError
include anIo
variant. -
ContentType::from_extension()
returns anOption<ContentType>
.For the old behvavior, use
.unwrap_or(ContentType::Any)
. -
The
IntoValue
config trait was removed in favor ofInto<Value>
.There is no workaround. Use
Into<Value>
as necessary. -
The
rocket_contrib::JSON
type has been renamed torocket_contrib::Json
.Use
Json
instead ofJSON
. -
All structs in the
content
module use TitleCase names.Use
Json
,Xml
,Html
, andCss
instead ofJSON
,XML
,HTML
, andCSS
, respectively.
In addition to new features, Rocket saw the following improvements:
- "Rocket" is now capatilized in the
Server
HTTP header. - The generic parameter of
rocket_contrib::Json
defaults tojson::Value
. - The trailing '...' in the launch message was removed.
- The launch message prints regardless of the config environment.
- For debugging,
FromData
is implemented forVec<u8>
andString
. - The port displayed on launch is the port resolved, not the one configured.
- The
uuid
dependency was updated to0.5
. - The
base64
dependency was updated to0.6
. - The
toml
dependency was updated to0.4
. - The
handlebars
dependency was updated to0.27
. - The
tera
dependency was updated to0.10
. yansi
is now used for all terminal coloring.- The
dev
rustc
release channel is supported during builds. Config
is now exported from the root.Request
implementsClone
andDebug
.- The
workers
config parameter now defaults tonum_cpus * 2
. - Console logging for table-based config values is improved.
PartialOrd
,Ord
, andHash
are now implemented forState
.- The format of a request is always logged when available.
- Route matching on
format
now functions as documented.
- All examples include a test suite.
- The
master
branch now uses a-dev
version number.
- Lints were updated for
2017-06-01
nightly. - Minimum required
rustc
is1.19.0-nightly (2017-06-01)
.
- Codegen was updated for
2017-05-26
nightly.
- Allow
k
andv
to be used as fields inFromForm
structures by avoiding identifier collisions (#265).
- Lints were updated for
2017-04-15
nightly. - Minimum required
rustc
is1.18.0-nightly (2017-04-15)
.
- Codegen was updated for
2017-03-30
nightly. - Minimum required
rustc
is1.18.0-nightly (2017-03-30)
.
- Multiple header values for the same header name are now properly preserved (#223).
- The
get_slice
andget_table
methods were added toConfig
. - The
pub_restricted
feature has been stabilized!
- Lints were updated for
2017-03-20
nightly. - Minimum required
rustc
is1.17.0-nightly (2017-03-22)
.
- The test script now denies trailing whitespace.
- Lints were updated for
2017-02-25
and2017-02-26
nightlies. - Minimum required
rustc
is1.17.0-nightly (2017-02-26)
.
Flash
cookie deletion functions as expected regardless of the path.config
properly accepts IPv6 addresses.- Multiple
Set-Cookie
headers are properly set.
Display
andError
were implemented forConfigError
.webp
,ttf
,otf
,woff
, andwoff2
were added as known content types.- Routes are presorted for faster routing.
into_bytes
andinto_inner
methods were added toBody
.
- Fixed
unmanaged_state
lint so that it works with prefilled type aliases.
- Better errors are emitted on Tera template parse errors.
- Fixed typos in
manage
andJSON
docs.
- Updated doctests for latest Cargo nightly.
Detailed release notes for v0.2 can also be found on rocket.rs.
This release includes the following new features:
- Introduced managed state.
- Added lints that warn on unmanaged state and unmounted routes.
- Added the ability to set configuration parameters via environment variables.
Config
structures can be built viaConfigBuilder
, which follows the builder pattern.- Logging can be enabled or disabled on custom configuration via a second
parameter to the
Rocket::custom
method. name
andvalue
methods were added toHeader
to retrieve the name and value of a header.- A new configuration parameter,
workers
, can be used to set the number of threads Rocket uses. - The address of the remote connection is available via
Request.remote()
. Request preprocessing overrides remote IP with value from theX-Real-IP
header, if present. - During testing, the remote address can be set via
MockRequest.remote()
. - The
SocketAddr
request guard retrieves the remote address. - A
UUID
type has been added tocontrib
. rocket
androcket_codegen
will refuse to build with an incompatible nightly version and emit nice error messages.- Major performance and usability improvements were upstreamed to the
cookie
crate, including the addition of aCookieBuilder
. - When a checkbox isn't present in a form,
bool
types in aFromForm
structure will parse asfalse
. - The
FormItems
iterator can be queried for a complete parse viacompleted
andexhausted
. - Routes for
OPTIONS
requests can be declared via theoptions
decorator. - Strings can be percent-encoded via
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 beingConfig
by value.A call in v0.1 of the form
Rocket::custom(&config)
is nowRocket::custom(config, false)
. -
Tera templates are named without their extension.
A templated named
name.html.tera
is now simplyname
. -
JSON
unwrap
method has been renamed tointo_inner
.A call to
.unwrap()
should be changed to.into_inner()
. -
The
map!
macro was removed in favor of thejson!
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 anInto<Header>
type directly. -
The
Content-Type
forString
is nowtext/plain
.Use
content::HTML<String>
for HTML-basedString
responses. -
Request.content_type()
returns anOption<ContentType>
.Use
.unwrap_or(ContentType::Any)
to get the old behavior. -
The
ContentType
request guard forwards when the request has noContent-Type
header.Use an
Option<ContentType>
and.unwrap_or(ContentType::Any)
for the old behavior. -
A
Rocket
instance must be declared before aMockRequest
.Change the order of the
rocket::ignite()
andMockRequest::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 asFormItems::from(string)
. -
from_from_string(&str)
inFromForm
removed in favor offrom_form_items(&mut FormItems)
.Most implementation should be using
FormItems
internally; simply use the passed inFormItems
. In other cases, the form string can be retrieved via theinner_str
method ofFormItems
. -
Config::{set, default_for}
are deprecated.Use the
set_{param}
methods instead ofset
, andnew
orbuild
in place ofdefault_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:
- Handlebars partials were not properly registered (#122).
Rocket::custom
did not set the custom configuration as theactive
configuration.- Route path segments containing more than one dynamic parameter were allowed.
In addition to new features, Rocket saw the following smaller improvements:
- Rocket no longer overwrites a catcher's response status.
- The
port
Config
type is now a properu16
. - Clippy issues injected by codegen are resolved.
- Handlebars was updated to
0.25
. - The
PartialEq
implementation ofConfig
doesn't consider the path or secret key. - Hyper dependency updated to
0.10
. - The
Error
type forJSON as FromData
has been exposed asSerdeError
. - SVG was added as a known Content-Type.
- Serde was updated to
0.9
. - Form parse failure now results in a 422 error code.
- Tera has been updated to
0.7
. pub(crate)
is used throughout to enforce visibility rules.- Query parameters in routes (
/path?<param>
) are now logged. - Routes with and without query parameters no longer collide.
- Testing was parallelized, resulting in 3x faster Travis builds.
- Hyper version pinned to 0.9.14 due to upstream non-semver breaking change.
- Fixed security checks in
FromSegments
implementation forPathBuf
.
proc_macro
feature removed from examples due to stability.
- Header names are treated as case-preserving.
- Minimum supported nightly is
2017-01-03
.
- Typo in
Outcome
formatting fixed (Succcess -> Success). - Added
ContentType::CSV
. - Dynamic segments parameters are properly resolved, even when mounted.
- Request methods are only overridden via
_method
field on POST. - Form value
String
s are properly decoded.
- The
_method
field is now properly ignored inFromForm
derivation. - Unknown Content-Types in
format
no longer result in an error. - Deriving
FromForm
no longer results in a deprecation warning. - Codegen will refuse to build with incompatible rustc, presenting error message and suggestion.
- Added
head
as a valid decorator forHEAD
requests. - Added
route(OPTIONS)
as a valid decorator forOPTIONS
requests.
- Templates with the
.tera
extension are properly autoescaped. - Nested template names are properly resolved on Windows.
- Template implements
Display
. - Tera dependency updated to version 0.6.
- Todo example requirements clarified in its
README
.
- Tests added for
config
,optional_result
,optional_redirect
, andquery_params
examples. - Testing script checks for and disallows tab characters.
- New script (
bump_version.sh
) automates version bumps. - Config script emits error when readlink/readpath support is bad.
- Travis badge points to public builds.
- Fix
get_raw_segments
index argument in route codegen (#41). - Segments params (
<param..>
) respect prefixes.
- Fix nested template name resolution (#42).
- New script (
publish.sh
) automates publishing to crates.io. - New script (
bump_version.sh
) automates version bumps.
NamedFile
Responder
lost its body in the shuffle; it's back!
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 newStatus
type.Response
type alias superceded byResponse
type.Responder::respond
no longer takes in hyper type.Responder::respond
returnsResponse
, takesself
by move.Handler
returnsOutcome
instead ofResponse
type alias.ErrorHandler
returnsResult
.- All
Hyper*
types were moved to unprefixed versions inhyper::
. MockRequest::dispatch
now returns aResponse
type.URIBuf
removed in favor of unifiedURI
.- Rocket panics when an illegal, dynamic mount point is used.
- Rocket handles
HEAD
requests automatically. - New
Response
andResponseBuilder
types. - New
Request
,Header
,Status
, andContentType
types.
MockRequest
allows any type of header.MockRequest
allows cookies.
- Debug output disabled by default.
- The
ROCKET_CODEGEN_DEBUG
environment variables enables codegen logging.
All incoming request data is now streamed. This resulted in a major change to the Rocket APIs. They are summarized through the following API changes:
- The
form
route parameter has been removed. - The
data
route parameter has been introduced. - Forms are now handled via the
data
parameter andForm
type. - Removed the
data
parameter fromRequest
. - Added
FromData
conversion trait and default implementation. FromData
is used to automatically derive thedata
parameter.Responder
s are now final: they cannot forward to other requests.Responser
s may only forward to catchers.
- Request
uri
parameter is private. Useuri()
method instead. form
module moved underrequest
module.response::data
was renamed toresponse::content
.- Introduced
Outcome
withSuccess
,Failure
, andForward
variants. outcome
module moved to top-level.Response
is now a type alias toOutcome
.Empty
Responder
was removed.StatusResponder
removed in favor ofresponse::status
module.
- Error handlers can now take 0, 1, or 2 parameters.
FromForm
derive now works on empty structs.- Lifetimes are now properly stripped in code generation.
- Any valid ident is now allowed in single-parameter route parameters.
- Route is now cloneable.
Request
no longer has any lifetime parameters.Handler
type now includes aData
parameter.http
module is public.Responder
implemented for()
type as an empty response.- Add
config::get()
for global config access. - Introduced
testing
module. Rocket.toml
allows global configuration via[global]
table.
- Added a
raw_upload
example. - Added a
pastebin
example. - Documented all public APIs.
- Now building and running tests with
--all-features
flag. - Added appveyor config for Windows CI testing.
- Remove
Rocket::new
in favor ofignite
method. - Remove
Rocket::mount_and_launch
in favor of chainingmount(..).launch()
. mount
andcatch
takeRocket
type by value.- All types related to HTTP have been moved into
http
module. Template::render
incontrib
now takes context by reference.
- Rocket now parses option
Rocket.toml
for configuration, defaulting to sane values. ROCKET_ENV
environment variable can be used to specify running environment.
- Document
ContentType
. - Document
Request
. - Add script that builds docs.
- Scripts can now be run from any directory.
- Cache Cargo directories in Travis for faster testing.
- Check that library version numbers match in testing script.
- Rename
response::data_type
toresponse::data
.
- Rocket interprets
_method
field in forms as the incoming request's method. - Add
Outcome::Bad
to signify responses that failed internally. - Add a
NamedFile
Responder
type that uses a file's extension for the response's content type. - Add a
Stream
Responder
for streaming responses.
- Introduce the
contrib
crate. - Add JSON support via
JSON
, which implementsFromRequest
andResponder
. - Add templating support via
Template
which implementsResponder
.
- Initial guide-like documentation.
- Add documentation, testing, and contributing sections to README.
- Add a significant number of codegen tests.