Commit Graph

928 Commits

Author SHA1 Message Date
Sergio Benitez 5931d6704b Split 'AdHoc::on_launch' into two by fallibility.
The new 'AdHoc::try_on_launch()' replaces the previous 'on_launch'. The
new 'on_launch' returns a 'Rocket' directly.
2021-04-07 23:09:05 -07:00
Sergio Benitez c45a83897f Allow several 'field' attributes in all derives.
In particular, 'FromFormField' and 'UriDisplayQuery' now allow any
number of form 'field' attributes. For the former, multiple 'value's are
allowed, all of which are used to match against incoming fields - any
match wins. For the latter, multiple 'name' and 'value's are allowed;
the first of each is used to render the query value.

Additionally, 'UriDisplayQuery' can now be derived for C-like enums.
This brings the derive to parity with 'FromFormValue' and allows their
unified application on C-like enums.

Resolves #843.
2021-04-07 23:09:05 -07:00
Sergio Benitez fd03417188 Emit a dummy 'Origin' in failed 'uri!' expansions.
This significantly reduces the number of spurious, fallout compiler
errors when the 'uri!' macros fails.
2021-04-07 23:09:05 -07:00
Sergio Benitez 3535d08ff8 Impl 'FromFormField' for 'Cow', 'Capped<Cow>'. 2021-04-07 23:09:05 -07:00
Sergio Benitez e157904524 Parse empty bool values as 'true'.
This allows a field 'f: bool' to parse as true for the query '?f'.
2021-04-07 23:09:05 -07:00
Sergio Benitez b29b7bf413 Clarify non-specificity driven collisions. 2021-04-07 23:09:05 -07:00
Sergio Benitez 49b65c3ccc Filter out 'r2d2' log messages in non-debug. 2021-04-07 23:09:05 -07:00
Sergio Benitez 8d28e845d9 Rename 'Flash' 'name', 'msg' to 'kind', 'message'.
This is now consistent with the serialization of 'Flash' and better
illustrates the purpose of the late 'name' property.

Additionally, take 'Into<String>' instead of 'AsRef<str>' so we only
allocate when necessary.
2021-04-07 23:09:05 -07:00
Sergio Benitez 764ea06e90 Preserve non-'Config' values in 'Client::debug()'. 2021-04-07 23:09:05 -07:00
Sergio Benitez 8a2592c257 Use multithreaded runtime in blocking client.
The runtime uses a single worker thread. Using a multithreaded runtime
allows futures that require a multithreaded runtime to run.
2021-04-07 23:09:05 -07:00
Sergio Benitez 6ad14dc3f6 Takes URIs as 'TryInto<Origin>' in local client.
In particular, this allows passing in type-safe URIs constructed via the
'uri!' macro, which was not possible before.
2021-04-07 23:09:05 -07:00
Sergio Benitez cb4b8a3fef Add 'percent_encode', 'strip' methods to 'RawStr'. 2021-04-07 23:09:05 -07:00
Sergio Benitez e92b2adeaa Introduce 'RawStrBuf', use in 'Origin::map_path()'.
'RawStrBuf' is the owned analog of 'RawStr'. Thus, 'Cow<RawStr>' is
either 'RawStr' or 'RawStrBuf'.
2021-04-07 23:09:05 -07:00
Sergio Benitez c0564fa8dc Reexport, implement 'Responder' for 'Either'. 2021-04-07 23:09:04 -07:00
Sergio Benitez 0bdb6b7bc7 Remove 'attach' fairings. Add 'liftoff' fairings.
Launch fairings are now fallible and take the place of attach fairings,
but they are only run, as the name implies, at launch time.

This is is a fundamental shift from eager execution of set-up routines,
including the now defunct attach fairings, to lazy execution,
precipitated by the transition to `async`. The previous functionality,
while simple, caused grave issues:

  1. A instance of 'Rocket' with async attach fairings requires an async
     runtime to be constructed.
  2. The instance is accessible in non-async contexts.
  3. The async attach fairings have no runtime in which to be run.

Here's an example:

```rust
let rocket = rocket::ignite()
    .attach(AttachFairing::from(|rocket| async {
        Ok(rocket.manage(load_from_network::<T>().await))
    }));

let state = rocket.state::<T>();
```

This had no real meaning previously yet was accepted by running the
attach fairing future in an isolated runtime. In isolation, this causes
no issue, but when attach fairing futures share reactor state with other
futures in Rocket, panics ensue.

The new Rocket application lifecycle is this:

  * Build - A Rocket instance is constructed. No fairings are run.
  * Ignition - All launch fairings are run.
  * Liftoff - If all launch fairings succeeded, the server is started.

New 'liftoff' fairings are run in this third phase.
2021-04-07 23:09:00 -07:00
Sergio Benitez 8d4d01106e Fix file name test for Windows. 2021-04-04 00:12:02 -07:00
Sergio Benitez c280a52a51 Fix compilation on Windows. 2021-04-03 19:40:58 -07:00
Sergio Benitez 579508d58f Make 'FileName' a DST. Improve sanitization.
Resolves #1594.
2021-04-03 17:09:00 -07:00
Jonah Brüchert fa1b75ba74 Allow accessing raw file name from 'DataField'. 2021-04-03 17:07:20 -07:00
Sergio Benitez 0654890e3d Add copy methods to 'TempFile'.
Resolves #1600.
2021-04-01 13:27:37 -07:00
Sergio Benitez 2893ce754d Introduce scoped catchers.
Catchers can now be scoped to paths, with preference given to the
longest-prefix, then the status code. This a breaking change for all
applications that register catchers:

  * `Rocket::register()` takes a base path to scope catchers under.
    - The previous behavior is recovered with `::register("/", ...)`.
  * Catchers now fallibly, instead of silently, collide.
  * `ErrorKind::Collision` is now `ErrorKind::Collisions`.

Related changes:

  * `Origin` implements `TryFrom<String>`, `TryFrom<&str>`.
  * All URI variants implement `TryFrom<Uri>`.
  * Added `Segments::prefix_of()`.
  * `Rocket::mount()` takes a  `TryInto<Origin<'_>>` instead of `&str`
    for the base mount point.
  * Extended `errors` example with scoped catchers.
  * Added scoped sections to catchers guide.

Internal changes:

  * Moved router code to `router/router.rs`.
2021-03-28 13:57:33 -07:00
Sergio Benitez c3bad3a287 Fix small typo in lib.rs. 2021-03-27 18:25:46 -07:00
Sergio Benitez feadb4dd16 Prefer '&str' in doc examples. 2021-03-27 16:25:39 -07:00
Sergio Benitez 3045e0ac63 Add doc notes on how to depend on '-dev' versions. 2021-03-27 14:20:43 -07:00
Sergio Benitez 78d749b265 Use explicit 'serde-1' 'indexmap' feature. 2021-03-27 14:10:38 -07:00
Sergio Benitez f7b32e0817 Update to latest 'multer'. 2021-03-27 03:37:37 -07:00
Sergio Benitez 4c0d66b6b1 Update 'pin-project-lite' to 0.2. 2021-03-27 01:03:46 -07:00
Sergio Benitez 3119e6f453 Redesign routing benchmarks.
The new benchmarks use routes from real-world project. This is much more
realistic than the previous benchmarks.

The new benchmarks use `criterion` and exist in their own Cargo project.
2021-03-26 20:02:49 -07:00
Sergio Benitez 20605dac14 Set default route rank using "colorings".
This new system colors paths and queries in one of three ways:

  1. `static`, meaning all components are static
  2. `partial`, meaning at least one component is dynamic
  3. `wild`, meaning all components are dynamic

Static paths carry more weight than static queries. The same is true for
partial and wild paths. This results in the following default rankings:

| path    | query   | rank |
|---------|---------|------|
| static  | static  | -12  |
| static  | partial | -11  |
| static  | wild    | -10  |
| static  | none    | -9   |
| partial | static  | -8   |
| partial | partial | -7   |
| partial | wild    | -6   |
| partial | none    | -5   |
| wild    | static  | -4   |
| wild    | partial | -3   |
| wild    | wild    | -2   |
| wild    | none    | -1   |
2021-03-26 19:41:00 -07:00
Sergio Benitez ec1ccc248c Test 'Limits::{find,get}' with tri-level limits. 2021-03-25 18:52:04 -07:00
Sergio Benitez 630a458417 Expose active 'Rocket' via 'Request::rocket()'. 2021-03-25 18:33:15 -07:00
Sergio Benitez 9cb2552055 Inline a few more 'Request' methods. 2021-03-25 18:19:34 -07:00
Sergio Benitez af598fb872 Use concrete lifetime in 'Request::uri()'. 2021-03-25 18:17:51 -07:00
Sergio Benitez e7934a2a3f Parse inner form 'T' in 'Option<T>' strictly.
This behavior more closely matches the expectation that a missing field
results in 'None'.

Also cleans up forms docs for readability, completeness.
2021-03-24 19:53:13 -07:00
Sergio Benitez 33790254f1 Store full '&Rocket' in '&Request'.
This is instead of storing pieces of the active Rocket instance.
2021-03-24 11:59:23 -07:00
Sergio Benitez 81346e5949 Don't expose hidden 'Route' collider methods. 2021-03-20 03:04:31 -07:00
Sergio Benitez b3021e2acb Fix all broken links. Update some outdated docs. 2021-03-19 18:09:13 -07:00
Sergio Benitez def9b4dcd2 Always emit 'Request<'_>', with lifetime. 2021-03-19 18:05:27 -07:00
Sergio Benitez 84fda62678 Emit query parse code only when there's a query. 2021-03-19 18:04:28 -07:00
Sergio Benitez 8749d7293a Simplify and optimize router.
This surfaced a dormant concurrency related issue. Prior to this commit,
the router used `routed_segments()` to retrieve the path segments of the
request. This was okay as there was no route in the request, and matched
segments were retrieved eagerly.

This commit makes segment matching lazy, so no matching occurs if
unnecessary. Between two matches, a `route` is atomically set of
`Request`. This is now visible in `routed_segments()`, which should not
have considered the current route in the first place. This was fixed.
2021-03-19 03:49:58 -07:00
Sergio Benitez 39d7931d6a Expose 'router' module, document 'RouteUri'. 2021-03-19 03:49:58 -07:00
Ben Sully 97acd8d9a9 Update tests and docstrings for 'RouteUri'. 2021-03-19 03:49:58 -07:00
Sergio Benitez 2463637d51 Introduce 'RouteUri'.
Co-authored-by: Ben Sully <ben@bsull.io>
2021-03-19 03:49:54 -07:00
Abdullah Alyan af48d1f2e6 Support more TLS key types in PKCS format.
Closes #1449.
Resolves #1461.
2021-03-17 18:23:15 -07:00
Sergio Benitez f254504dc9 Depend on a single revision of 'state'.
Closes #1577.
2021-03-15 02:46:34 -07:00
Sergio Benitez 1b2edd38b3 Clarify 'TempFile' configuration parameters. 2021-03-15 02:43:01 -07:00
Sergio Benitez f9d4a78fbb Fix spacing in 'Route::default_rank()'. 2021-03-15 02:39:21 -07:00
Sergio Benitez 9c678e606b Track and log catcher names. 2021-03-15 02:27:53 -07:00
Sergio Benitez 304e65ac72 Catch panics that occur before future is returned.
In the course of resolving this issue, double-boxing of handlers was
discovered and removed.
2021-03-15 02:20:48 -07:00
Sergio Benitez 70b42e6f0e Remove second lifetime from 'FromRequest'.
While offering some utility, the lifetime did not carry its weight, and
in practice offered no further ability to borrow. This greatly
simplifies request guard implementations.
2021-03-14 19:57:59 -07:00
Sergio Benitez e532f4e2b3 Disallow defaults in strict forms.
Partially resolves #1536.
2021-03-11 02:03:13 -08:00
Sergio Benitez c0caa3b874 Fix codegen doctests for 'Route.name' changes. 2021-03-10 22:28:06 -08:00
Sergio Benitez a0e4c9677c Allow dynamic route names. Log 'StaticFiles' root. 2021-03-10 18:40:38 -08:00
Sergio Benitez 191b93498e Remove boxed futures in server, use async fn. 2021-03-10 16:31:32 -08:00
Sergio Benitez 3c25326917 Log only non-empty fairing classes. 2021-03-10 02:30:13 -08:00
Sergio Benitez 497c4765f2 Fix typo in 'Rocket::ignite()' docs. 2021-03-10 02:16:59 -08:00
Sergio Benitez bc38196f8d Generate a secret key in debug only if it is zero.
This prevents printing a secret key warning if a secret key was
generated, as is done by Rocket itself. This does not change any
behaviors in non-debug profiles.
2021-03-10 02:13:50 -08:00
Sergio Benitez 4e06ee64aa Test 'secret_key' validation, now on pre-launch.
Prior to this commit, it was not possible to test Rocket crates in
production mode without setting a global secret key or bypassing secret
key checking - the testing script did the latter. The consequence is
that it became impossible to test secret key related failures because
the tests passed regardless.

This commit undoes this. As a consequence, all tests are now aware of
the difference between debug and release configurations, the latter of
which validates 'secret_key' by default. New 'Client::debug()' and
'Client::debug_with()' simplify creating an instance of 'Client' with
configuration in debug mode to avoid undesired test failures.

The summary of changes in this commit are:

  * Config 'secret_key' success and failure are now tested.
  * 'secret_key' validation was moved to pre-launch from 'Config:from()'.
  * 'Config::from()' only extracts the config.
  * Added 'Config::try_from()' for non-panicking extraction.
  * 'Config' now knows the profile it was extracted from.
  * The 'Config' provider sets a profile of 'Config.profile'.
  * 'Rocket', 'Client', 'Fairings', implement 'Debug'.
  * 'fairing::Info' implements 'Copy', 'Clone'.
  * 'Fairings' keeps track of, logs attach fairings.
  * 'Rocket::reconfigure()' was added to allow modifying a config.

Internally, the testing script was refactored to properly test the
codebase with the new changes. In particular, it no longer sets a rustc
'cfg' to avoid secret-key checking.

Resolves #1543.
Fixes #1564.
2021-03-09 21:57:26 -08:00
Sergio Benitez 83ffe0f7bc Remove 'Config::profile()'. CFG 'secret_key' field.
This commit makes the `Config.secret_key` conditionally compile on the
`secrets` feature. The net effect is simplified internal code, fewer
corner-cases, and easier to write tests.

This commit removes the `Provider::profile()` implementation of
`Config`. This means that the `Config` provider no longer sets a
profile, a likely confusing behavior. The `Config::figment()` continues
to function as before.
2021-03-09 21:40:53 -08:00
Jeb Rosen d778c2cb10 Drop embedded async 'Client' in async runtime. 2021-03-06 01:40:43 -08:00
Sergio Benitez 68b244ebdc Forward catcher, handler failure to 500 catcher.
This changes core routing so that panics in all handlers are handled by
emitting a long message explaining that panics are bad and invoking the
500 error catcher. If the 500 error catcher fails, Rocket's default 500
catcher is used.
2021-03-06 01:39:31 -08:00
Jeb Rosen a0784b4b15 Catch and gracefully handle panics in routes and catchers. 2021-03-05 22:58:28 -08:00
Sergio Benitez 7784cc982a Allow multiple and uncased field renamings. 2021-03-05 18:09:12 -08:00
Sergio Benitez 5ed3c13240 Remove 'extern crate's in generated URI macro.
Resolves #1554.
2021-03-05 14:21:52 -08:00
Sergio Benitez 4d0042c395 Allow '<path..>' to match zero segments.
This changes core routing so that '<path..>' in a route URI matches zero
or more segments. Previously, '<path..>' matched _1_ or more.

  * Routes '$a' and '$b/<p..>' collide if $a and $b previously collided.
  * For example, '/' now collides with '/<p..>'.
  * Request '$a' matches route '$b/<p..>' if $a previously matched $b.
  * For example, request '/' matches route '/<p..>'.

Resolves #985.
2021-03-05 02:01:24 -08:00
Sergio Benitez 08ae0d0b8c Use upstream 'async-trait'. 2021-03-04 22:10:59 -08:00
Sergio Benitez 3bce76f5af Use 'Client::debug()' in more tests. 2021-03-04 21:53:22 -08:00
Sergio Benitez 67fef233a0 Fix 'rocket::local' docstring import spacing. 2021-03-04 21:53:22 -08:00
Sergio Benitez 58f365dac4 Always return 'Segments' from 'Request::segments()'.
The iterator may be empty. This changes the return type of
'Request::segments()' from 'Option<Segments>' to simply 'Segments'.

Internally also adds a 'Client::debug()' for easier request testing.
2021-03-04 21:53:22 -08:00
Sergio Benitez 5977fe1236 Impl 'Deref' to 'Request' for 'LocalRequest'. 2021-03-04 21:53:22 -08:00
Sergio Benitez 630f2c1105 Remove unused 'RouteUriError::Segment' variant. 2021-03-04 02:49:29 -08:00
Sergio Benitez a3946377f7 Use 'UriPart::Kind' to avoid unreachable match arms. 2021-03-04 02:48:07 -08:00
Sergio Benitez 7628546ca2 Improve 'FromForm' derive error spans. 2021-03-04 02:11:06 -08:00
Sergio Benitez 398a044eb0 Complete forms documentation. Improve 'validate'.
* Add a `msg!()` macro to easily change a field validation message.
  * Allow a field to refer to itself via `self.field`.
  * Improve the various field validation traits.
2021-03-04 02:08:40 -08:00
Sergio Benitez 78e2f8a3c9 Revamp codegen, fixing inconscpicuous bugs.
This commit completely revamps the way that codegen handles route URI
"parameters". The changes are largely internal. In summary, codegen code
is better organized, better written, and less subject to error.

There are three breaking changes:
  * `path` is now `uri` in `route` attribute: `#[route(GET, path = "..")]`
    becomes `#[route(GET, uri = "..")]`.
  * the order of execution for path and query guards relative to
    each-other is now unspecified
  * URI normalization now normalizes the query part as well.

Several error messages were improved. A couple of bugs were fixed:
  * Prior to this commit, Rocket would optimistically try to parse every
    segment of a URI as an ident, in case one was needed in the future.
    A bug in rustc results in codegen "panicking" if the segment
    couldn't _lex_ as an ident. This panic didn't manifest until far
    after expansion, unfortunately. This wasn't a problem before as we
    only allowed ident-like segments (ASCII), but now that we allow any
    UTF-8, the bug surfaced. This was fixed by never attempting to parse
    non-idents as idents.
  * Prior to this commit, it was impossible to generate typed URIs for
    paths that ignored path parameters via the recently added syntax
    `<_>`: the macro would panic. This was fixed by, well, handling
    these ignored parameters.

Some minor additions:
  * Added `RawStr::find()`, expanding its `Pattern`-based API.
  * Added an internal mechanism to dynamically determine if a `UriPart`
    is `Path` or `Query`.
2021-03-04 02:01:25 -08:00
Sergio Benitez 63a14525d8 UTF-8 routes. Forms revamp. Temp files. Capped.
So. Many. Changes.

This is an insane commit: simultaneously one of the best (because of all
the wonderful improvements!) and one of the worst (because it is just
massive) in the project's history.

Routing:
  * All UTF-8 characters are accepted everywhere in route paths. (#998)
  * `path` is now `uri` in `route` attribute: `#[route(GET, path = "..")]`
    becomes `#[route(GET, uri = "..")]`.

Forms Revamp
  * All form related types now reside in a new `form` module.
  * Multipart forms are supported. (resolves #106)
  * Collections are supported in forms and queries. (resolves #205)
  * Nested structures in forms and queries are supported. (resolves #313)
  * Form fields can be ad-hoc validated with `#[field(validate = expr)]`.
  * `FromFormValue` is now `FromFormField`, blanket implements `FromForm`.
  * Form field values are always percent-decoded apriori.

Temporary Files
  * A new `TempFile` data and form guard allows streaming data directly to a
    file which can then be persisted.
  * A new `temp_dir` config parameter specifies where to store `TempFile`.
  * The limits `file` and `file/$ext`, where `$ext` is the file extension,
    determines the data limit for a `TempFile`.

Capped
  * A new `Capped` type is used to indicate when data has been truncated due to
    incoming data limits. It allows checking whether data is complete or
    truncated.
  * `DataStream` methods return `Capped` types.
  * `DataStream` API has been revamped to account for `Capped` types.
  * Several `Capped<T>` types implement `FromData`, `FromForm`.
  * HTTP 413 (Payload Too Large) errors are now returned when data limits are
    exceeded. (resolves #972)

Hierarchical Limits
  * Data limits are now hierarchical, delimited with `/`. A limit of `a/b/c`
    falls back to `a/b` then `a`.

Core
  * `&RawStr` no longer implements `FromParam`.
  * `&str` implements `FromParam`, `FromData`, `FromForm`.
  * `FromTransformedData` was removed.
  * `FromData` gained a lifetime for use with request-local data.
  * The default error HTML is more compact.
  * `&Config` is a request guard.
  * The `DataStream` interface was entirely revamped.
  * `State` is only exported via `rocket::State`.
  * A `request::local_cache!()` macro was added for storing values in
    request-local cache without consideration for type uniqueness by using a
    locally generated anonymous type.
  * `Request::get_param()` is now `Request::param()`.
  * `Request::get_segments()` is now `Request::segments()`, takes a range.
  * `Request::get_query_value()` is now `Request::query_value()`, can parse any
    `FromForm` including sequences.
  * `std::io::Error` implements `Responder` like `Debug<std::io::Error>`.
  * `(Status, R)` where `R: Responder` implements `Responder` by overriding the
    `Status` of `R`.
  * The name of a route is printed first during route matching.
  * `FlashMessage` now only has one lifetime generic.

HTTP
  * `RawStr` implements `serde::{Serialize, Deserialize}`.
  * `RawStr` implements _many_ more methods, in particular, those related to the
    `Pattern` API.
  * `RawStr::from_str()` is now `RawStr::new()`.
  * `RawStr::url_decode()` and `RawStr::url_decode_lossy()` only allocate as
    necessary, return `Cow`.
  * `Status` implements `Default` with `Status::Ok`.
  * `Status` implements `PartialEq`, `Eq`, `Hash`, `PartialOrd`, `Ord`.
  * Authority and origin part of `Absolute` can be modified with new
    `Absolute::{with,set}_authority()`, `Absolute::{with,set}_origin()` methods.
  * `Origin::segments()` was removed in favor of methods split into query and
    path parts and into raw and decoded versions.
  * The `Segments` iterator is smarter, returns decoded `&str` items.
  * `Segments::into_path_buf()` is now `Segments::to_path_buf()`.
  * A new `QuerySegments` is the analogous query segment iterator.
  * Once set, `expires` on private cookies is not overwritten. (resolves #1506)
  * `Origin::path()` and `Origin::query()` return `&RawStr`, not `&str`.

Codegen
  * Preserve more spans in `uri!` macro.
  * Preserve spans `FromForm` field types.
  * All dynamic parameters in a query string must typecheck as `FromForm`.
  * `FromFormValue` derive removed; `FromFormField` added.
  * The `form` `FromForm` and `FromFormField` field attribute is now named
    `field`. `#[form(field = ..)]` is now `#[field(name = ..)]`.

Contrib
  * `Json` implements `FromForm`.
  * `MsgPack` implements `FromForm`.
  * The `json!` macro is exported as `rocket_contrib::json::json!`.
  * Added clarifying docs to `StaticFiles`.

Examples
  * `form_validation` and `form_kitchen_sink` removed in favor of `forms`.
  * The `hello_world` example uses unicode in paths.
  * The `json` example only allocates as necessary.

Internal
  * Codegen uses new `exports` module with the following conventions:
    - Locals starts with `__` and are lowercased.
    - Rocket modules start with `_` and are lowercased.
    - `std` types start with `_` and are titlecased.
    - Rocket types are titlecased.
  * A `header` module was added to `http`, contains header types.
  * `SAFETY` is used as doc-string keyword for `unsafe` related comments.
  * The `Uri` parser no longer recognizes Rocket route URIs.
2021-03-04 01:51:21 -08:00
Jeb Rosen 9d45e786bb Update 'rand' dependency to 0.8. 2021-02-28 16:34:38 -08:00
Rudi Floren e332ee83da Add missing lifetime parameter in codegen for routes and catchers.
This is linted against by `elided_lifetimes_in_paths`, which is not
enabled by default but is part of the `rust_2018_idioms` lint group.
2021-02-28 15:59:45 -08:00
Jeb Rosen 87f03d3b26 Update UI tests for latest nightly and 'pear' error messages. 2021-02-26 22:15:37 -08:00
ami-GS 38e4067a58 Fix invalid JSON syntax in doc examples: remove trailing commas. 2021-02-20 12:01:44 -08:00
Jeb Rosen 453fa037da Update UI tests for latest stable. 2021-02-20 12:01:44 -08:00
Sergio Benitez aaea84d750 Check profile in jail to avoid env races. 2021-02-19 12:49:39 -08:00
Sergio Benitez 2a49368313 Update UI tests for latest nightly. 2021-02-09 17:17:44 -08:00
Sergio Benitez 0af25bfb6d Move derive attribute after derive. 2021-02-09 17:17:26 -08:00
Sergio Benitez e325e2fce4 Fix soundness issue: make 'Formatter' panic-safe.
Fixes #1534.
2021-02-09 16:58:34 -08:00
Sergio Benitez c24f15c18f Add regression test for #1503.
Closes #1503.
2021-01-14 15:15:57 -08:00
Sergio Benitez 407e346a6a Clean up 'on_launch_fairing_can_inspect_port' test. 2021-01-13 17:20:44 -08:00
Filip Gospodinov 48fd83a31d Run launch fairings after effective port is known. 2021-01-13 17:20:33 -08:00
Sergio Benitez 43ade920c5 Warn when deprecated profiles are set. 2021-01-13 16:21:36 -08:00
Sergio Benitez 28976a5bd3 Preserve 'secret_key' in 'Config' provider data.
Also fixes emission of 'secret_key' warnings when 'secrets' feature is
disabled.

Resolves #1505.
Fixes #1510.
2021-01-13 16:01:39 -08:00
Jeb Rosen 92af8fca72 Update to 'tokio' 1.0, 'hyper' 0.14. 2021-01-13 15:22:16 -08:00
Sergio Benitez 031948c1da Remove superfluous semicolons. 2021-01-13 14:30:08 -08:00
Brendon Federko cb33429ce4 Enable 'std' 'indexmap' feature. 2021-01-12 14:52:37 -08:00
Brendon Federko e68a951a54 Upodate tests for latest stable. 2021-01-12 14:52:34 -08:00
Sergio Benitez 9671115796 Use 'workers' value from 'Config::figment()'.
This commit also improves config pretty-printing and warning messages.
It also fixes an issue that resulted in config value deprecation
warnings not being emitted. The 'workers' value is now a 'usize', not a
'u16'; contrib pool sizes now default to 'workers * 2'.

Closes #1470.
2020-12-24 15:58:48 -08:00
Jeb Rosen 1f1f44f336 Update UI tests for latest stable. 2020-11-21 12:42:57 -08:00
Sergio Benitez fa77435187 Bust cache on 'Request::{add,replace}_header()'.
Also changes 'Header::name()' to return '&UncasedStr'.

Resolves #518.
2020-11-05 21:03:58 -08:00
Sergio Benitez 86ff66a69c Streamline raw identifier support in codegen. 2020-11-03 12:07:23 -08:00
Jeb Rosen 97f6bc5dc0 Support raw identifiers in forms, routes, uri.
Resolves #881.
2020-11-03 01:42:37 -08:00
Sergio Benitez b5e4dded8a Accept browser-sent unencoded query characters.
Closes #941.

Co-authored-by: Vladimir Ignatev <ya.na.pochte@gmail.com>
2020-11-02 15:08:33 -08:00
Sergio Benitez 949bb01e2d Generate path encoding set using 'const fn'.
Co-authored-by: Jakub Wieczorek <jakub.adam.wieczorek@gmail.com>
2020-11-01 21:26:31 -08:00
Sergio Benitez 337e8843a4 Use 'Option', 'Result' directly in 'uri!' query.
Prior to this commit, the conversion 'T -> Option<T>' was applied in
both the path and query parts of a URI in the 'uri' macro via the
'FromUriParam' trait with no implementation for 'Option<T>' directly.
This meant that it was impossible to directly render an 'Option<T>'.
This was exactly desired for the path part, where rendering a 'None'
would yield an incorrect URI, but the restriction was too strict for the
query part, where a 'None' is entirely valid. This commit makes changes
the conversion so that it only applied to path parts and adds the
identity conversions for 'Option<T>' and 'Result<T, E>' for query parts.

The side effect is a breaking change: due to conflicting impls, the 'T'
to 'Option<T>' conversion was removed for query parts. Thus, all 'uri!'
query route arguments of type 'Option' or 'Result' must now be wrapped
in 'Some' or 'Ok'. Due to new 'Option<T> <-> Result<T, E>' conversions,
either 'Some' _and_ 'Ok' work in both contexts.

Closes #1420.
2020-11-01 10:30:30 -08:00
Sergio Benitez edc91f65b7 Mimic Rocket's config in custom providers example. 2020-10-30 03:08:26 -07:00
Sergio Benitez 55b651bd70 Use 'rocket::custom()' for 'State' tests. 2020-10-30 02:49:00 -07:00
Jonty b7565172eb Impl 'Clone' for 'State'.
Resolves #1411.
2020-10-30 02:16:24 -07:00
Sergio Benitez a6f5a63535 Add tests for ignored parameters '<_>'.
Co-authored-by: timokoesters <timo@koesters.xyz>
2020-10-30 00:47:41 -07:00
Sergio Benitez 8e8fb4cae8 Allow ignored route path segments.
Co-authored-by: timokoesters <timo@koesters.xyz>
2020-10-30 00:06:39 -07:00
Sergio Benitez 23738446f0 Impl 'std::error::Error' for 'Error'.
Resolves #1460.
2020-10-27 16:04:25 -07:00
Sergio Benitez 8570afff3e Use threaded scheduler in tests.
This prevents async I/O timeouts in attach fairings.

Co-authored-by: Jeb Rosen <jeb@jebrosen.com>
2020-10-26 13:29:36 -07:00
Sergio Benitez 09f0087034 Split server parts of 'Rocket' into 'server.rs'. 2020-10-22 18:00:07 -07:00
Sergio Benitez 198b6f0e97 Fix various broken rustdoc links. 2020-10-22 03:53:07 -07:00
Sergio Benitez 08510302da Add 'Rocket::catchers()', rearrange other getters. 2020-10-22 03:41:02 -07:00
Sergio Benitez ec9b5816a8 Remove 'rocket::inspect()', 'Cargo'.
This commit reverts most of dea940c7 and d89c7024. The "fix" is to run
attach fairings on a new thread. If a runtime is already running, it is
used. Otherwise, the future is executed in a single-threaded executor.
2020-10-22 03:27:04 -07:00
Sergio Benitez 17fd7f4286 Update minimum rustc to 1.46. 2020-10-21 19:56:12 -07:00
Sergio Benitez bbfe2ba5cc Point all docs and doc links to 'master' branch. 2020-10-21 04:54:24 -07:00
George Cheng 0673986c32 Impl 'FromRequest' for 'IpAddr'.
Closes #1414.
2020-10-20 20:51:26 -07:00
ThouCheese 080d586a35 Impl 'DerefMut' for 'Form', 'LenientForm'. 2020-10-20 20:45:43 -07:00
est31 b18cd6460e Add AVIF (image/avif) as a known media type. 2020-10-20 20:40:18 -07:00
Sergio Benitez 730a2dcdbe Implement 'Serialize' for 'Flash'.
Resolves #184.
2020-10-20 20:29:55 -07:00
Sergio Benitez 7337321efb Take '&mut Data' in 'on_request' fairings.
Resolves #1438.
2020-10-20 20:22:32 -07:00
Sergio Benitez 1fb061496d Revamp configuration.
This commit completely overhauls Rocket's configuration systems, basing
it on the new Figment library. It includes many breaking changes
pertaining to configuration. They are:

  * "Environments" are replaced by "profiles".
  * 'ROCKET_PROFILE' takes the place of 'ROCKET_ENV'.
  * Profile names are now arbitrary, but 'debug' and 'release' are given
    special treatment as default profiles for the debug and release
    compilation profiles.
  * A 'default' profile now sits along-side the meta 'global' profile.
  * The concept of "extras" is no longer present; users can extract any
    values they want from the configured 'Figment'.
  * The 'Poolable' trait takes an '&Config'.
  * The 'secrets' feature is disabled by default.
  * It is a hard error if 'secrets' is enabled under the 'release'
    profile and no 'secret_key' is configured.
  * 'ConfigBuilder' no longer exists: all fields of 'Config' are public
    with public constructors for each type.
  * 'keep_alive' is disabled with '0', not 'false' or 'off'.
  * Inlined error variants into the 'Error' structure.
  * 'LoggingLevel' is now 'LogLevel'.
  * Limits can now be specified in SI units: "1 MiB".

The summary of other changes are:

  * The default config file can be configured with 'ROCKET_CONFIG'.
  * HTTP/1 and HTTP/2 keep-alive configuration is restored.
  * 'ctrlc' is now a recognized config option.
  * 'serde' is now a core dependency.
  * TLS misconfiguration errors are improved.
  * Several example use '_' as the return type of '#[launch]' fns.
  * 'AdHoc::config()' was added for simple config extraction.
  * Added more documentation for using 'Limits'.
  * Launch information is no longer treated specially.
  * The configuration guide was rewritten.

Resolves #852.
Resolves #209.
Closes #1404.
Closes #652.
2020-10-20 19:21:56 -07:00
Sergio Benitez 8da034ab83 Update 'devise'. 2020-10-15 01:01:30 -07:00
Sergio Benitez 5615767ca6 Add proper 'cfg' to 'get_private_pending()'. 2020-10-15 00:46:30 -07:00
Sergio Benitez 5cf249581f Add 'const' constructor for 'MediaType'. 2020-10-14 23:54:37 -07:00
Sergio Benitez 079e458b62 Add (un)tracked 'Client' integration tests. 2020-10-14 21:47:42 -07:00
Sergio Benitez 5d9035ddc1 Keep an op-log for sync 'CookieJar'.
In brief, this commit:

  * Updates to the latest upstream 'cookie', fixing a memory leak.
  * Make changes to 'CookieJar' observable only through 'pending()'.
  * Deprecates 'Client::new()' in favor of 'Client::tracked()'.
  * Makes 'dispatch()' on tracked 'Client's synchronize on cookies.
  * Makes 'Client::untracked()' actually untracked.

This commit updates to the latest 'cookie' which removes support for
'Sync' cookie jars. Instead of relying on 'cookie', this commit
implements an op-log based 'CookieJar' which internally keeps track of
changes. The API is such that changes are only observable through
specialized '_pending()' methods.
2020-10-14 21:37:16 -07:00
Sergio Benitez 2f330d2967 Allow return type of '#[launch]' fn to be elided. 2020-10-12 22:32:02 -07:00
Sergio Benitez 092e03f720 Generate a proxy structure for better namespacing.
Prior to this commit, it was impossible to 'use' a route from a separate
namespace for use in a 'routes!' macro. Naturally, this was a common
source of confusion amongst users. This commit obviates this deficiency
by generating a "proxy" structure that can be imported and converted
into a 'Route'/'Catcher' or their static variants.

This change is largely backwards compatible but can break existing code
when routes are named identically to other types in the namespace.
2020-10-12 22:11:44 -07:00
Edwin Svensson 29f4726127 Fix typo in 'Form::into_inner' docs: unclosed codeblock. 2020-10-11 12:49:18 -07:00
Jeb Rosen 83a7fc48d2 Update UI tests for latest nightly. 2020-10-11 12:21:45 -07:00
Sergio Benitez 1369dc47a3 Update 'atomic' and 'ubyte' dependencies. 2020-09-11 01:20:44 -07:00
Sergio Benitez adbf1caab2 Migrate to upstream 'uncased'. 2020-09-11 01:13:55 -07:00
Sergio Benitez f7eacb6a65 Tidy 'form_value_from_encoded_str' test. 2020-09-10 02:15:29 -07:00
lewis 53d13a309b Decode in 'FromFormValue' as needed by 'FromStr'.
Fixes #1425.
2020-09-10 02:07:54 -07:00
Jeb Rosen f976c15c25 Update UI tests for latest nightly. 2020-09-06 18:34:24 -07:00
Jeb Rosen dc2c6ecd8a Update UI tests for latest stable. 2020-08-31 18:51:38 -07:00
Sergio Benitez 52320020bc Use thread-safe 'CookieJar's.
The user-facing changes effected by this commit are:

  * The 'http::Cookies<'_>' guard is now '&http::CookieJar<'_>'.
  * The "one-at-a-time" jar restriction is no longer imposed.
  * 'CookieJar' retrieval methods return 'http::CookieCrumb'.
  * The 'private-cookies' feature is now called 'secrets'.
  * Docs flag private cookie methods with feature cfg.
  * Local, async request dispatching is never serialized.
  * 'Client::cookies()' returns the tracked 'CookieJar'.
  * 'LocalResponse::cookies()' returns a 'CookieJar'.
  * 'Response::cookies()' returns an 'impl Iterator'.
  * A path of '/' is set by default on all cookies.
  * 'SameSite=strict' is set by default on all cookies.
  * 'LocalRequest::cookies()' accepts any 'Cookie' iterator.
  * The 'Debug' impl for 'Request' prints the cookie jar.

Resolves #1332.
2020-08-16 02:19:45 -07:00
Sergio Benitez 549c9241c4 Require data limits on 'Data::open()'.
Closes #1325.
2020-08-06 02:46:04 -05:00
Sergio Benitez 45b4436ed3 Add default catchers: '#[catch(default)]'.
The bulk of the changes in this commit are for creating an
'ErrorHandler' trait that works like the 'Handler' trait, but for
errors. Furthermore, Rocket's default catcher now responds with a JSON
payload if the preferred 'Accept' media type is JSON.

This commit also fixes a bug in 'LocalRequest' where the internal
'Request' contained an correct 'URI'.
2020-07-30 01:55:41 -07:00
Sergio Benitez e531770989 Make URI modifications to 'Route' codegen-safe.
This commit aims to make it impossible to modify a 'Route' structure in
a way that violates expectations of a code-generated 'Route'. It removes
'Route::set_uri()' in favor of 'Route::map_base()', which allows for
safe modifications of the route's base.

In a similar vain, this commit also includes the following changes:

  * 'Route::path()' was added to safely retrieve the route's 'path'.
  * The base of a 'Route' is underlined during launch printing.
  * 'Origin::into_normalized()' replaces 'Origin::to_normalized()'.

Fixes #1262.
2020-07-29 16:38:24 -07:00
Jonathan Dickinson f3beb68491 Remove superfluous lifetimes in 'Fairing' methods. 2020-07-23 21:32:20 -07:00
Sergio Benitez 754b1e0e31 Panic if 'StaticFiles' directory doesn't exist. 2020-07-23 20:12:20 -07:00
Sergio Benitez 261cb400d1 Don't use managed state to thread 'Shutdown'. 2020-07-22 19:22:32 -07:00
Sergio Benitez adc79016cd Rearrange top-level exports. Use '#[launch]'.
This commits makes the following high-level changes:

  * 'ShutdownHandle' is renamed to 'Shutdown'.
  * 'Rocket::shutdown_handle()' is renamed to 'Rocket::shutdown()'.
  * '#[launch]` is preferred to '#[rocket::launch]'.
  * Various docs phrasings are improved.
  * Fixed various broken links in docs.

This commits rearranges top-level exports as follows:

  * 'shutdown' module is no longer exported.
  * 'Shutdown' is exported from the crate root.
  * 'Outcome' is not longer exported from the root.
  * 'Handler', 'ErrorHandler' are no longer exported from the root.
2020-07-22 16:10:02 -07:00
Necmettin Karakaya fde6eda915 Fix various typos throughout the codebase. 2020-07-22 12:56:01 -07:00
Jeb Rosen 8d779caa22 Note lower ranks are higher precedence in 'Route'.
Fixes #1360.
2020-07-22 12:28:56 -07:00
Sergio Benitez ddfd73d6f3 Delete broken symlinks to 'update-references.sh'.
Fixes #1385.
2020-07-22 06:52:04 -07:00
Sergio Benitez 56a6172625 Enable compilation with stable Rust.
To the Rust teams, Rust's contributors, Rocket's contributors, the
entire Rust and Rocket communities, my colleagues at Stanford and
beyond, and Jeb: thank you all. Sincerely.

To the next ~4 years of Rocket!

Closes #19.
2020-07-21 16:30:45 -07:00
Sergio Benitez b47d1b8f0f Rework docs for stable and async support. 2020-07-21 16:15:13 -07:00
Sergio Benitez cd7e99a535 Use 'bencher' for benchmarks on stable. 2020-07-21 15:31:44 -07:00
Sergio Benitez 9a2149b43d Test guide and README using stable 'doc_comment'. 2020-07-21 15:31:44 -07:00
Sergio Benitez 67efe143c5 Improve diagnostics, especially on stable. 2020-07-21 15:31:42 -07:00
Sergio Benitez 1858403203 Implement codegen testing on stable.
This commits migrates to 'trybuild' from 'compiletest' for codegen
diagnostic testing.
2020-07-21 15:11:07 -07:00
Sergio Benitez 95a4b442cc Update Pear to 0.2. 2020-07-21 15:11:07 -07:00
Jeb Rosen 27b26188c4 Update 'toml' to '0.5'. 2020-07-21 15:11:07 -07:00
Jeb Rosen fb42bf9ee2 Upgrade 'tokio-rustls' to 0.14. 2020-07-21 10:54:07 -07:00
Jakub Wieczorek 6f1cefff10 Upgrade 'percent-encoding' to 2.
Co-authored-by: Jeb Rosen <jeb@jebrosen.com>
2020-07-21 10:54:07 -07:00
Jeb Rosen 7f276eb2fc Update 'devise' to the latest commit. 2020-07-20 23:26:36 -07:00
Sergio Benitez 0909ba2ef6 Only enable testing features on 'cfg(test)'. 2020-07-16 05:49:38 -07:00
Sergio Benitez 3f2b8f6006 Remove 'proc_macro' features. 2020-07-16 05:46:39 -07:00
Sergio Benitez 7bcf82a199 Improve catcher mismatched type errors. 2020-07-14 02:48:46 -07:00
Sergio Benitez dfca18d307 Generate 'uri!' macro names independently of span.
Prior to this commit, codegen used 'Span' information to generate a
unique id for a given route. This commit changes the id generation to
instead use 1) the route's name and path, 2) a an per-generation
atomically increasing ID, and 3) the ids of the process/thread the
proc-macro is running in. Together, these values should provide a unique
id for a given route, even in the face of the reused processes and
threads, while also removing the dependence on unstable Span features.

Fixes #1373.
2020-07-14 00:44:59 -07:00
Sergio Benitez 816b8c44ab Ignore 'snake_case' warnings for 'tmp' variables. 2020-07-14 00:43:48 -07:00
Sergio Benitez a87e3ad9f5 Remove superfluous empty lines. 2020-07-12 02:38:28 -07:00
Sergio Benitez 33e95f4900 Rename 'FromDataSimple' to 'FromData'. Make async.
The 'FromData' trait becomes 'FromTransformedData'.
2020-07-12 02:23:00 -07:00
Sergio Benitez f4c82d7ffe Remove unnecessary 'dev-dependencies'. 2020-07-11 11:27:23 -07:00
Sergio Benitez 62355b424f Remove use of stable 'proc_macro_hygiene' feature. 2020-07-11 10:48:08 -07:00
Sergio Benitez 08b34e8263 Fix and re-enable UI tests. 2020-07-11 09:24:30 -07:00
Sergio Benitez 832408ea9b Add example requiring async testing. 2020-07-11 09:24:30 -07:00
Jeb Rosen 06975bfaea Use the blocking testing API everywhere.
Co-authored-by: Sergio Benitez <sb@sergio.bz>
2020-07-11 09:24:30 -07:00
Sergio Benitez 6482fa2fba Rework 'local' module. Add 'LocalResponse' methods.
This completes the 'local' blocking client implementation.
2020-07-11 09:24:30 -07:00
Jeb Rosen 050a2c6461 Document new 'local' structures. 2020-07-11 09:24:30 -07:00
Sergio Benitez 03127f4dae Add blocking variant of 'local'.
This commit adds the 'local::blocking' module and moves the existing
asynchronous testing to 'local::asynchronous'. It also includes several
changes to improve the local API, bringing it to parity (and beyond)
with master. These changes are:

  * 'LocalRequest' implements 'Clone'.
  * 'LocalResponse' doesn't implement 'DerefMut<Target=Response>'.
    Instead, direct methods on the type, such as 'into_string()', can
    be used to read the 'Response'.
  * 'Response::body()' returns an '&ResponseBody' as opposed to '&mut
    ResponseBody', which is returned by a new 'Response::body_mut()'.
  * '&ResponseBody' implements 'known_size()` to retrieve a body's size,
    if it is known.

Co-authored-by: Jeb Rosen <jeb@jebrosen.com>
2020-07-11 09:24:30 -07:00
Sergio Benitez 824de061c3 Enable configurable 'ctrl-c' shutdown by default.
This removes the 'ctrl_c_shutdown' feature opting instead for a 'ctrlc'
configuration option. To avoid further merge conflicts with the master
branch, the option is currently read as an extra.

Co-authored-by: Jeb Rosen <jeb@jebrosen.com>
2020-07-11 09:24:30 -07:00
Sergio Benitez 9277ddafdf Swap 'Rocket' manually without using 'replace_with'. 2020-07-11 09:24:30 -07:00
Sergio Benitez 3ced188f7d Use 'ref-cast' for safer transparent casting. 2020-07-11 09:24:30 -07:00
Sergio Benitez d89c7024ed Replace 'Manifest' with 'Cargo'.
This is largely an internal change. Prior to this commit, the 'Manifest'
type, now replaced with the 'Cargo' type, robbed responsibility from the
core 'Rocket' type. This new construction restores the previous
responsibility and makes it clear that 'Cargo' is _only_ for freezing,
and representing the stability of, Rocket's internal state.
2020-07-11 09:24:30 -07:00
Sergio Benitez dd5b518cc2 Ignore 'unused_imports' warning on cfg-based 'FutureExt'. 2020-07-11 09:24:30 -07:00
Sergio Benitez 1704ff7743 Asyncify 'Handler'. Rename 'ErrorHandlerFuture' to 'CatcherFuture'. 2020-07-11 09:24:30 -07:00
Sergio Benitez f7cd455558 Make 'NamedFile' async. Fix 'Handler' trait.
Previously, 'NamedFile::open()' called a synchronous I/O method. This
commit changes it to instead use tokio's 'File' for async I/O.

To allow this to change, the 'Handler' trait was fixed to enforce that
the lifetime of '&self', the reference to the handler, outlives the
incoming request. As a result, futures returned from a handler can hold
a reference to 'self'.
2020-07-11 09:24:30 -07:00
Sergio Benitez 2465e2f136 Make 'Responder' trait sync; fix its lifetimes.
In summary, this commit modifies 'Responder' so that:

  * ..it is no longer 'async'. To accommodate, the 'sized_body' methods
    in 'Response' and 'ResponseBuilder' are no longer 'async' and accept
    an optional size directly. If none is supplied, Rocket will attempt
    to compute the size, by seeking, before writing out the response.
    The 'Body' type was also changed to differentiate between its sized
    'Seek' and chunked body variants.

  * ..'&Request' gains a lifetime: 'r, and the returned 'Response' is
    parameterized by a new 'o: 'r. This allows responders to return
    references from the request or those that live longer.
2020-07-11 09:24:29 -07:00
Sergio Benitez 12308b403f Add '#[rocket::launch]' attribute.
The attribute is applied everywhere it can be across the codebase and is
the newly preferred method for launching an application. This commit
also makes '#[rocket::main]` stricter by warning when it is applied to
functions other than 'main'.
2020-07-11 09:24:29 -07:00
Jeb Rosen c7c371910b Remove extraneous dependency on 'futures-util'. 2020-07-11 09:24:29 -07:00
Jeb Rosen bc1b90cbdb Add '#[rocket::main]' attribute and make 'launch()' an 'async fn'.
'#[rocket::main]' works like '#[rocket::async_test]', but it uses
tokio's multithreaded scheduler.
2020-07-11 09:24:29 -07:00
Jeb Rosen 7a62653cdd Add a test verifying that attempting to manage the same state type twice panics. 2020-07-11 09:24:29 -07:00
Jeb Rosen e72058de81 Add 'config()' and 'state()' functions directly to 'Rocket' for convenience. 2020-07-11 09:24:29 -07:00
Jeb Rosen b0238e5110 Make 'Fairing::on_attach()' async.
This transitively requires that 'Rocket::inspect()', 'Client::new()',
and 'Client::untracked()' also become async.
2020-07-11 09:24:29 -07:00
Jeb Rosen dea940c7a8 Defer execution of operations on 'Rocket' until their effects will be
observed.

This is a prerequisite for async on_attach fairings. 'Rocket' is now a
builder wrapper around the 'Manifest' type, with operations being
applied when needed by 'launch()', 'Client::new()', or 'inspect()'.
'inspect()' returns an '&Manifest', which now provides the methods that
could be called on an '&Rocket'.
2020-07-11 09:24:29 -07:00
Sergio Benitez 8696dd94af Make references to core types absolute in codegen.
Prior to this commit, codegen emitted tokens containing bare types like
'Result' and 'Box' as well as presumed imported variants such as 'None'
and 'Ok'.  However, users are free to shadow these, and if they do, the
generated code will fail to compile, or worse, be incorrect. To avoid
this, this commit makes all references to these core types and imports
absolute.
2020-07-11 09:24:29 -07:00
Jeb Rosen 71b888c2fa Fix AddrParseError when the incoming connection's remote_addr is not known. 2020-07-11 09:24:29 -07:00
Jeb Rosen 2ca15b663a Update minimum nightly to '2019-12-29'.
This version of rustc was the first to ship with a version of cargo that
supports 'proc_macro' without an 'extern crate' declaration.
2020-07-11 09:24:29 -07:00
Sergio Benitez 98a90808b4 Fix an array of broken doc links. 2020-07-11 09:24:29 -07:00
Sergio Benitez c0c6c79a7f Use 'async_trait' for 'Responder'.
Also:

  * Remove 'response::ResultFuture'.
  * Re-export 'tokio' and 'futures' from the crate root.
  * Make 'ResponseBuilder::sized_body()' and 'async fn'.
  * Remove the 'Future' implementation for 'ResponseBuilder'.
  * Add 'ResponseBuilder::finalize()' for finalizing the builder.
2020-07-11 09:24:29 -07:00
Sergio Benitez 58f81d392e Simplify async 'Response' methods. 2020-07-11 09:24:29 -07:00
Sergio Benitez 431b963774 Use 'async_trait' for 'FromRequest'.
Removes 'FromRequestAsync'.
2020-07-11 09:24:29 -07:00
Sergio Benitez 48c333721c Use 'async_trait' for 'Fairing' trait.
Also re-exports the 'async_trait' attribute from 'rocket'.
2020-07-11 09:24:29 -07:00
Sergio Benitez a4e7972b4b Remove unnecessary 'extern crate's. 2020-07-11 09:24:29 -07:00
Sergio Benitez 73484f1a88 Implement 'Responder' for 'tokio::fs::File'. 2020-07-11 09:24:29 -07:00
Michael Howell 5f3baf240a Deduplicate response streaming code for sized and chunked bodies. 2020-07-11 09:24:29 -07:00
Jeb Rosen d5483cb196 Clean up Error handling.
* Implement `std::error::Error` for the new Error type.
* Document the new Error type.
* Remove `LaunchError`'s implementation of `Error::description`, which is deprecated.
2020-07-11 09:24:29 -07:00
Jeb Rosen 85761c08e3 Fix deprecation warning: 'tokio::runtime::Builder::num_threads' -> 'core_threads'. 2020-07-11 09:24:29 -07:00
Michael Howell c9d0af09d6 Use 'AsyncSeek' for sized bodies in 'Response's.
In order to avoid making 'ResponseBuilder::sized_body' an asynchronous
function, the seeking is deferred until finalization. 'finalize()' is
replaced with '.await', and 'ResponseBuilder::ok()' is an 'async fn'.
2020-07-11 09:24:29 -07:00
Jeb Rosen dcd4068ca0 Move a debug-only 'use' in 'from_data.rs' to the locations where it is actually used. 2020-07-11 09:24:29 -07:00
Jeb Rosen e41abc09e5 Update more API documentation to mention futures and async. 2020-07-11 09:24:29 -07:00
Jeb Rosen 9a16aeb2e0 Use async fn instead of impl Future in a few methods in 'Data' and 'Rocket'. 2020-07-11 09:24:29 -07:00
Jeb Rosen f442642ec2 Fix request URI tests. 2020-07-11 09:24:29 -07:00
Jeb Rosen 49f4641871 Clean up handling of body data:
* Minor code and comment tweaks
* Remove dynamic dispatch inside Data and DataStream
2020-07-11 09:24:29 -07:00
Jeb Rosen 571e2ac845 Revert incoming request URI and header parsing to more closely match 0.4. 2020-07-11 09:24:29 -07:00
Jeb Rosen c2da8a21d8 Change a panic to an error when a client sends a request but disconnects before a response can be sent. 2020-07-11 09:24:29 -07:00
Jeb Rosen 70096c1bd4 Revert on_response lifetimes to more closely match 0.4. 2020-07-11 09:24:29 -07:00
Jeb Rosen 4bb4c61528 Allow implementations of on_request fairings to return a Future that borrows from self, request, and data. 2020-07-11 09:24:29 -07:00
Jeb Rosen cc3298c3e4 Allow implementations of FromData to return a Future that borrows from the request. 2020-07-11 09:24:29 -07:00
Jeb Rosen 468f4d9314 Simplify FromRequestAsync trait definition. 2020-07-11 09:24:29 -07:00
Paolo Barbolini 003bf77c29 Upgrade to tokio 0.2.0.
* Update 'tokio', 'tokio-rustls', and 'hyper'.
* Remove unused dependencies on some `futures-*` crates.
* Rework 'spawn_on', which is now 'serve'.
* Simplify Ctrl-C handling.
2020-07-11 09:24:29 -07:00
Jeb Rosen 7c4cd068d1 Update for rust-lang/rust#64856.
Raise the nightly version to one that accepts '...(format!(...)).await'.

This additionally reverts commit bdbf80f2da.
2020-07-11 09:24:29 -07:00
Jeb Rosen df52616074 Update error positions after changes for async #[catch] support. 2020-07-11 09:24:29 -07:00
Jeb Rosen 2fa2d636e4 Implement FromRequestAsync instead of FromRequest for Option and Result. 2020-07-11 09:24:29 -07:00
Jeb Rosen 4e5b889358 Add async-routes test for #[get] and #[catch]. 2020-07-11 09:24:29 -07:00
Follpvosten 189fd65b17 Add 'Request::local_cache_async' for use in async request guards. 2020-07-11 09:24:29 -07:00
Jeb Rosen 5317664893 Fix UI tests for FromRequestAsync. 2020-07-11 09:24:29 -07:00
Jeb Rosen 1c28a9413b Allow catchers to be async fn. 2020-07-11 09:24:29 -07:00
Jeb Rosen adf7e4233a Add 'FromRequestAsync' and use it in route codegen.
'FromRequestAsync' is automatically implemented for all types
that implement 'FromRequest'.
2020-07-11 09:24:29 -07:00
Jeb Rosen ea06878581 Update 'hyper', 'futures-*-preview', and 'tokio-*' dependencies.
Use I/O traits and types from 'tokio-io' as much as possible.

A few adapters only exist in futures-io-preview and use
futures-tokio-compat as a bridge for now.
2020-07-11 09:24:29 -07:00
Jeb Rosen 0d89637e8b Propagate errors while writing out response instead of panicking. 2020-07-11 09:24:28 -07:00
Jeb Rosen 8718561bf8 Emit an error when #[async_test] is applied to a function with parameters. 2020-07-11 09:24:28 -07:00
Jeb Rosen d1815e527f Update 'hyper', 'tokio', and 'tokio-rustls'.
* hyper -> 0.13.0-alpha.2
* tokio -> 0.2.0-alpha.5
* tokio-rustls -> 0.12.0-alpha.3
2020-07-11 09:24:28 -07:00
Jeb Rosen af36f299c6 Fix ordering of messages in a UI test. 2020-07-11 09:24:28 -07:00
Jeb Rosen 523c6099fb Replace use of 'hyper::AddrIncoming' with a Listener API and implement TLS.
Types can now implement the new 'Listener' trait, which means they can
report the address they are listening on and asynchronously accept
connections. 'Connection's are read/write streams that can additionally
report the remote address.

Listener is implemented for 'tokio_net::tcp::TcpListener' and for
the new 'rocket_http::tls::TlsListener' based on 'tokio-rustls'.

The new private function 'Rocket::listen_on()' now does the main setup
for launch and is generic over a Listener. In the future, a more refined
version of the API can be exposed so that applications can implement
their own listeners.
2020-07-11 09:24:28 -07:00
Jeb Rosen 62a99e9e49 Fix a minor compilation error, possibly caused by rust-lang/rust#64292. 2020-07-11 09:24:28 -07:00
Jeb Rosen 77a64c73bb Fix some launch error handling in tests and examples. 2020-07-11 09:24:28 -07:00
Jeb Rosen a0d2651e38 Fix a few unused import warnings. 2020-07-11 09:24:28 -07:00
Jacob Pratt cd6a80c230 Implement an API to request a graceful shutdown.
Additionally listen for Ctrl-C as a shutdown signal by default.
2020-07-11 09:24:28 -07:00
Jeb Rosen 0d6e46944b Use tokio's current_thread runtime for async_test to increase performance. 2020-07-11 09:24:28 -07:00
Jacob Pratt c7ecfc69c3 Use 'futures::future::BoxFuture' instead of 'Pin<Box<...>>' for readability. 2020-07-11 09:24:28 -07:00
Jacob Pratt bd929ef617 Remove unnecessary boxing of some Futures. 2020-07-11 09:24:28 -07:00
Jacob Pratt 1f90a9b6d1 Update hyper to '=0.13.0-alpha.1'. 2020-07-11 09:24:28 -07:00
Jeb Rosen baa2ed27f3 Update UI tests affected by removal of typed headers. 2020-07-11 09:24:28 -07:00
Jeb Rosen 047b1620f9 Update pinned hyper and tokio versions. 2020-07-11 09:24:28 -07:00
Jacob Pratt 05426881b0 Use 'File' from 'async_std' instead of from 'tokio'.
Additionally pin tokio to '=0.2.0-alpha.2'; before this change cargo
selects '0.2.0-alpha.3' which hyper does not compile against.
2020-07-11 09:24:28 -07:00
Jeb Rosen 560f0977d3 Revamp testing system for async.
* body_string_wait and body_bytes_wait are removed; use `.await` instead
* `dispatch()` is now an async fn and must be .await-ed
* Add `#[rocket::async_test]` macro, similar in purpose to `tokio::test`
* Tests now use either `rocket::async_test(async { })` or
  `#[rocket::async_test]` in order to `.await` the futures returned
  from `dispatch()` and `body_{string,bytes}()`
* Update 'test.sh' to reflect the tests that should be passing.

Broken:

* Cloned dispatch and mut_dispatch() with a live previous response now both fail, due to a (partial) check for mutable aliasing in LocalRequest.
* Some tests are still failing and need example-specific changes.
2020-07-11 09:24:28 -07:00
Jacob Pratt a87e1577aa Add 'Rocket::spawn_on' to spawn a server on a user-provided (tokio) runtime. 2020-07-11 09:24:28 -07:00
Jacob Pratt e44c5896b8 Remove stabilized 'async_await' feature gate and update the minimum nightly version. 2020-07-11 09:24:28 -07:00
Jeb Rosen af95129590 Use futures 0.3-compatible hyper and tokio and the tokio runtime instead
of futures-rs executor.

Despite this change, using body_bytes_wait on (for example) a File will
still fail due to tokio-rs/tokio#1356.
2020-07-11 09:24:28 -07:00
Jeb Rosen 8c8598b4fd Fix 'static_files' and 'serve' tests. 2020-07-11 09:24:28 -07:00
Jeb Rosen b780f9d8e0 Fix or ignore remaining doc tests in 'core'.
This adds an unstable "async_test" function for use in tests, to ensure
they stay working while refactoring other APIs.
2020-07-11 09:24:28 -07:00
Jeb Rosen aee7f35095 Use read_to_string (from futures-preview 0.3.0-alpha.18) to more closely match the pre-async code. 2020-07-11 09:24:28 -07:00
Jacob Pratt 0e6841da66 Convert two internal functions returning `Pin<Box<_>>` to `async fn`. 2020-07-11 09:24:28 -07:00
Jeb Rosen b56e889a0e Disable some known-failing tests for now. 2020-07-11 09:24:28 -07:00
Jeb Rosen 633e495a6b Update many doc tests in 'core' for async. 2020-07-11 09:24:28 -07:00
Jeb Rosen 1601e5c814 Fix a few 'unused use' warnings. 2020-07-11 09:24:28 -07:00
Jeb Rosen 6044961680 Update parts of contrib and associated tests and examples:
* json
  * templates
  * helmet
  * databases
  * serve
  * examples/cookies
  * examples/handlebars_templates
  * examples/json
  * examples/session
  * examples/static_files
  * examples/tera_templates
2020-07-11 09:24:28 -07:00
Jeb Rosen 7c34a3a93e Make 'Fairing::on_response' and 'Responder::respond_to' async.
This is required to be able to do anything useful with the body in the
outgoing response. Request fairings do not appear to need to be async
as everything on Data that returns a future moves self and on_request only
gets &Data, but the same change in this commit should work for on_request
if desired.
2020-07-11 09:24:28 -07:00
Jeb Rosen 5d439bafc0 Convert core to async and add support for async routes.
Minimum rustc bump required for rust-lang/rust#61775
2020-07-11 09:24:28 -07:00
Marc Schreiber 96b4142156 Upgrade to hyper 0.12.
* Use hyper's 'MakeService' implementation with futures API.
  * Use tokio runtime to serve HTTP backend.
2020-07-11 09:24:03 -07:00
Sergio Benitez 263e39b5b4 Always override config defaults with env vars.
Fixes a regression introduced in f7b1089.
2020-07-08 19:39:28 -07:00
gcarq 86d0bdddb2 Replace manual ASCII checks with 'std::char' calls. 2020-06-22 05:07:14 -07:00
Sergio Benitez 83925bbae1 Use clearer variables names in guide test macro.
Also removes latent, unnecessary 'guide' test.
2020-06-14 18:56:45 -07:00
Sergio Benitez 74f15a7ab5 Use top-level doc image URLs. 2020-06-11 02:30:14 -07:00
Sergio Benitez 63a4ae0485 Silence warnings on 'extern crate proc_macro'. 2020-06-08 12:25:10 -07:00
Sergio Benitez 55d2b2bfb6 Properly mock 'Key::try_generate()'. 2020-06-07 04:02:35 -07:00
Sergio Benitez f7b1089b49 Allow setting config path via 'ROCKET_CONFIG_FILE'. 2020-06-07 03:46:43 -07:00
Sergio Benitez a4301c0a9a Add 'Config::read()' and 'Config::read_from()'.
The former method allows constructing a 'Config' in the exact manner
Rocket does internally: reading the active environment's properties from
'Rocket.toml' and overriding values from environment variables. The
'read_from()' property does the same except it allows a custom config
file path.

This PR also improves the internal structure of the configuration code.
2020-06-07 02:42:15 -07:00
Sergio Benitez ea9865ec42 Allow multiple versions of 'rustls' and 'ring'.
Co-authored-by: TotalKrill <kristoffer.odmark90@gmail.com>
2020-06-04 18:59:11 -07:00
Sergio Benitez 3c47fa895a Enable minimal set of 'cookie' features. 2020-06-04 18:54:23 -07:00
Jeb Rosen 91fb0804be Hide docs for more generated items. 2020-06-04 18:01:20 -07:00
Sergio Benitez 3f20e4ac93 Use proper SPDX license expression in 'Cargo.toml'. 2020-06-03 23:02:05 -07:00
Jeb Rosen 097fbd7df0 Fix some broken links in API documentation. 2020-05-31 11:32:14 -07:00
Yusuke Kominami a21221aeb6 Replace deprecated 'OffsetDateTime::now' with 'OffsetDateTime::now_utc'.
Update 'time' dependency accordingly.
2020-05-30 11:13:40 -07:00
Nia Watts ea81f8e07b Fix typo in 'Query' documentation: 'mplementation' -> 'implementation'. 2020-05-30 11:09:42 -07:00
Sergio Benitez ee5988fe5c Update 'cookie' to '0.14'. 2020-05-30 01:49:32 -07:00
Sergio Benitez 578038619f Add 'Origin::map_path()' method. 2020-05-29 17:49:37 -07:00
Sergio Benitez b8f9011c04 Fix 'LocalRequest::clone()' soundness issue.
The existing implementation of 'LocalRequest::clone()' mistakenly copied
the internal 'Request' pointer from the existing 'LocalRequest' to the
cloned 'LocalRequest'. This resulted in an aliased '*mut Request'
pointer, a clear soundness issue. The fix in this commit is to clone the
internal 'Request', replacing the internal pointer with the newly cloned
'Request' when producing the cloned 'LocalRequest'. A fix that removes
all 'unsafe' code should be explored.

Fixes #1312.
2020-05-27 01:09:12 -07:00
Alex Macleod ca4d1572d4 Hide emoji on Windows.
Closes #1122.
2020-05-17 15:30:48 -07:00
Sergio Benitez a8b029e423 Properly delimit length and name in flash cookies.
Fixes #1263.
2020-05-16 17:55:54 -07:00
Thiago Veronezi 94a222f6fe Fix typo in 'State' documentation: missing backtick. 2020-04-21 18:47:17 -07:00
Jeb Rosen 3abafaaedb Update UI tests for latest nightly. 2020-04-21 18:12:08 -07:00
Sergio Benitez 06e146e7d1 Update 'time' to 0.2 in 'contrib'. 2020-03-25 14:39:55 -07:00
Sergio Benitez 53353df633 Fix more broken links. 2020-03-09 02:03:38 -07:00
Sorin Davidoi dfc9e9aab0 Improve accessibility of default error HTML. 2020-03-02 16:39:19 -08:00
Sergio Benitez 32e86c3b69 Inline macro docs into core crate. 2020-02-25 16:56:59 -08:00
Sergio Benitez 95c981de79 Test all guide code examples.
Every code example is now fully runnable and testable. As a result, all
examples are now tested and include imports. Relevant imports are shown
by default. Code examples can be expanded to show all imports.

Fixes #432.
2020-02-15 04:02:19 -08:00
Sergio Benitez ee1a9903b6 Update UI tests for latest nightly. 2020-02-15 03:51:56 -08:00
Sergio Benitez 385b69cf69 Migrate to 'binascii' for base 16, 64 decoding. 2020-02-14 17:14:37 -08:00
Sergio Benitez 9f0e02fe27 Make references to core types absolute in codegen.
Prior to this commit, codegen emitted tokens containing bare types like
'Result' and 'Box' as well as presumed imported variants such as 'None'
and 'Ok'.  However, users are free to shadow these, and if they do, the
generated code will fail to compile, or worse, be incorrect. To avoid
this, this commit makes all references to these core types and imports
absolute.
2020-02-06 21:16:45 -08:00
Sergio Benitez d0bfd8a3bb Update 'cookie' to 0.13.2. 2020-01-29 14:17:01 -08:00
Sergio Benitez f35e3c4aca Set cookies even on error responses.
Fixes #1213.
2020-01-23 21:10:04 -08:00
Sergio Benitez 7c1b8dc9ad Update 'cookie' to 0.13, 'rustls' to 0.16. 2020-01-21 16:10:04 -08:00
Jeb Rosen ff2000293c Update 'compiletest' and fix and re-enable compile UI tests. 2020-01-15 17:09:57 -08:00
A. L 859224a209 Add additional Responder wrappers for some common HTTP status codes:
* 204 NoContent
* 401 Unauthorized
* 403 Forbidden
* 409 Conflict
2020-01-15 11:41:19 -08:00
Paolo Barbolini cd5f96ae15 Update 'uuid', 'unicode-xid', and 'base64' dependencies. 2019-11-30 09:33:14 -08:00
Michael Howell 121210c55c Add support for base16-encoded (a.k.a. hex-encoded) secret keys. 2019-11-29 12:06:55 -08:00
Jeb Rosen 96235615ce Update compile tests for changes in rust nightly. 2019-11-29 11:18:32 -08:00
Jeb Rosen 343f51d550 Disable UI tests for now. 2019-11-29 11:18:26 -08:00
Jeb Rosen e7e84a6d41 Fix and update benchmarks. 2019-11-16 13:08:36 -08:00
Matt Brubeck 8bf6aa2068 Update 'smallvec' to '1.0'. 2019-11-16 13:02:50 -08:00
Jacob Pratt 4e6a7ddd5f Remove use of the 'crate_visibility_modifier' feature.
Most items with 'crate' visibility become 'pub(crate)'.
Items are made 'pub' instead when they would remain private.
2019-09-21 09:16:04 -07:00
Jeb Rosen 335d8f7dbb Adjust '#[catch]' codegen output to fix a UI test regression in latest nightly. 2019-09-21 08:33:16 -07:00
Jacob Pratt bed93133b8 Abide by formatting in 'Debug' implementations. 2019-09-18 19:06:08 -07:00
Jacob Pratt e3c1a4ad3a Remove use of the 'try_trait' feature.
Add the 'try_outcome' macro to replace uses of '?' on 'Outcome'.
2019-09-18 18:43:16 -07:00
Jacob Pratt b95b6765e1 Remove use of 'label_break_value' feature. 2019-09-10 17:27:40 -07:00
Sergio Benitez 2537a1164d Remove 'Result' specialization. Add 'Debug' responder.
This removes all uses of specialization in Rocket.
2019-09-09 21:57:33 -07:00
Sergio Benitez 592e441de5 Use proper span in responder codegen output. 2019-09-09 21:57:10 -07:00
Sergio Benitez 3fae9919f7 Deprecate 'Result<T, E>, E: !Responder' responder. 2019-09-09 21:56:55 -07:00
Sergio Benitez 22da02fa64 Remove double semicolons; silence test warnings. 2019-09-09 16:57:03 -07:00
Sergio Benitez b7e688cefa Remove use of deprecated 'IndexMap::remove()'.
Use 'IndexMap::swap_remove()' in its place.
2019-09-09 16:51:51 -07:00
Sergio Benitez 99a864008c Remove use of specialization in http. 2019-09-09 16:45:03 -07:00
Sergio Benitez 6ed4c098f1 Stop exporting 'mime' and relevant conversions. 2019-09-09 16:42:44 -07:00
Sergio Benitez c5973f01df Remove use of specialization in 'status::Created'. 2019-09-09 16:37:46 -07:00
Sergio Benitez 0b059e06e5 Update 'devise' to 0.3.
This transitively updates 'syn', 'proc-macro2', and 'quote' to 1.0.
2019-09-05 15:44:25 -07:00
Sergio Benitez dcea9563fc Update UI tests for latest nightly. 2019-08-26 12:48:32 -07:00
Jacob Pratt 2dd09f90be Remove unused 'doc_cfg' feature. 2019-08-06 14:01:35 -07:00
Jeb Rosen 3e4f8453ce Remove use of the 'decl_macro' feature.
Also removes one internal use in the 'typed-uris' codegen test.
2019-07-19 11:39:56 -07:00
Jeb Rosen 2f458b5217 Remove dependence on 'decl_macro' in codegen.
The generated 'uri' helper macros are now re-exports of 'macro_rules'
macros, made possible by the stable 'uniform_paths' feature.
2019-07-19 11:38:35 -07:00
Jacob Pratt 34a741a26e Remove use of '!' type in favor of 'Infallible'.
This removes the use of and dependence on the 'never_type' feature.
2019-07-09 15:10:51 -07:00
Sergio Benitez 21b10176ee Forward from 'StaticFiles' if a file is not found.
Also adds a 'handler::Outcome::from_or_forward' method for easily
constructing handler outcomes that forward on responder failures.

Fixes #1036.
2019-07-07 23:22:38 -07:00
Dmitry Murzin c100a92127 Implement 'FromParam' for 'NonZero*' types. 2019-07-06 13:32:08 -07:00
Sergio Benitez 7f2c9f426c Fix tests for Windows. 2019-07-06 00:59:01 -07:00
Jeb Rosen be784a7845 Migrate codegen to Rust 2018. 2019-06-25 13:45:27 -04:00
Jeb Rosen 34cb1c14b8 Migrate core to Rust 2018. 2019-06-25 13:45:23 -04:00
Jeb Rosen 90e37beb2f Migrate http to Rust 2018. 2019-06-25 13:43:53 -04:00
Thomas Lent 42f8af411e Fix type in 'Data' rustdocs: 'T' -> 'DataGuard'. 2019-06-11 15:04:54 -07:00
Jeb Rosen 2d924f0f51 Allow 'non_snake_case' for generated query params.
Also adds '#[deny(non_snake_case)]' to the complete route generation
test for regressions.

Fixes #1003.
2019-05-29 19:18:46 -07:00
Sergio Benitez e458df094f Update 'version_check' to 0.9. 2019-05-24 01:48:42 -07:00
jeb 6bf751fb22 Reexport derive macros alongside derived traits. 2019-05-22 22:19:47 -07:00
Brenden Matthews ba6aa2f05e Bump cookie, rustls, and hyper-sync-rustls dependencies. 2019-05-14 22:25:55 -07:00
Sergio Benitez 1caf87eb21 Move to 0.5.0-dev on master. 2019-05-13 16:18:48 -07:00
Richard Petrie 75d2ea96d9 Replace deprecated 'isatty' with 'atty'. 2019-05-10 18:21:58 -07:00
Sergio Benitez 3e7a20ae57 Clarify defaults in 'Config' documentation. 2019-05-10 16:39:41 -07:00
Sergio Benitez fdd76ecf7e Clean up 'AdHoc' fairing implementation. 2019-05-09 09:04:31 -07:00
Sergio Benitez 7c2dda2647 Clean up 'Server' header commentary. 2019-05-08 20:20:26 -07:00
Sergio Benitez 9f75e0f443 Clean up 'conditionally-set-server-header' test. 2019-05-08 20:18:10 -07:00
lu4nm3 0a978fdb5d Set default 'Server' header only if it isn't set.
Closes #996.
2019-05-08 20:18:10 -07:00
Jeb Rosen 3c51a2f401 Update compiler tests for 2019-04-19 nightly. 2019-04-20 08:17:19 -07:00
Konrad Borowski 7ab1c427b5 Replace uses of `FnBox`; `Box<dyn FnOnce>` now implements `FnOnce`. 2019-04-13 09:15:27 -07:00
Jacob Pratt 9b219ddc01 Remove stabilized feature gates.
* try_from
* transpose_result
2019-04-12 18:48:51 -07:00
Oliver Scherer c86f4312fb Always produce a valid, if conservative, subspan. 2019-02-08 18:03:53 -08:00
Sergio Benitez f0c6c9b26f Use explicit associated type in 'IntoOwned' impl. 2019-02-06 19:37:39 -08:00
Sergio Benitez de9a98edd2 Update 'Rocket::custom()' docs to match signature.
Resolves #910.
2019-02-06 17:18:53 -08:00
Chris Foster 4921af459f Fix typo in 'LenientForm' docstring: 'gaurd' -> 'guard'. 2019-01-31 20:15:10 -08:00
jeb afd08ffb20 Update compiler tests for 2018-12-28 nightly. 2018-12-29 09:31:14 -08:00
Sergio Benitez ca5623c641 Type encoding to fix encoding issues once and for all.
Fixes #849.
2018-12-12 17:38:36 -08:00
Sergio Benitez 5056705884 Improve query string routing and typed URI docs. 2018-12-07 12:09:15 -08:00
Sergio Benitez b88a2d7d05 Add notes about enabling features to contrib docs. 2018-12-07 09:07:27 -08:00
Sergio Benitez a4dcb0cf4c New version: 0.4.0. 2018-12-06 09:19:11 -08:00
Sergio Benitez 7fb6ba9be5 Generate 'FromUriParam' impls in 'UriDisplayPath'. 2018-12-06 09:00:01 -08:00
Sergio Benitez d7933dd6fd Implement ignorable 'uri!' expressions.
Closes #840.
2018-12-06 08:43:24 -08:00
Sergio Benitez 90a6749313 New version: 0.4.0-rc.2. 2018-11-30 21:00:18 -08:00
Sergio Benitez 7919ceac39 Strip dev-dependencies more reliably. 2018-11-30 20:58:29 -08:00
Sergio Benitez 5ec21d5ba0 Update dependencies to published versions. 2018-11-30 09:00:16 -08:00
Sergio Benitez ac823861c8 Systematically name and span codegen variables.
Fixes #839.
2018-11-30 08:43:31 -08:00
Sergio Benitez b7db74144f Parameterize 'UriDisplay' with 'Path' or 'Query'.
This commit introduces the sealed `UriPart` marker trait as well as the
implementing `Path` and `Query` marker types, allowing for parts of a
URI to be distinguished at the type level. Consequently, `UriDisplay`
has been parameterized with `P: UriPart`, creating `UriDisplay<Path>`
and `UriDisplay<Query>`. The effect of this change is improved type
safely for URI rendering as well as the ability to omit rendering values
in query parts via `Option` and `Result`.

The `UriDisplay` derive was replaced by `UriDisplayQuery` and
`UriDisplayPath` which derive implementations for `UriDisplay<Path>`
and `UriDisplay<Query>`, respectively.

This commit also works around a rustdoc visibility issue by creating a
hidden `http::private` module.

Finally, this commit also removes the now vestigial use of the
`rustc_private` feature in codegen.

Fixes #827.
2018-11-27 10:01:47 -06:00
Sergio Benitez 543b07a4ba Use upstream 'Literal::subspan()'. 2018-11-23 19:15:13 -06:00
jeb ed4055925d Use 'dyn' in codegen to silence 'bare_trait_objects' lint. 2018-11-19 02:34:46 -08:00
Sergio Benitez abb434f228 Stop using white for legible logging everywhere.
Prior to this change, Rocket emitted "white" text in much of its logging
output. On terminals with light backgrounds, the text was nearly
illegible. This PR stops using white coloring altogether, opting instead
to use the terminal's default color albeit with bold styling. On dark
terminals, this will likely be a light color, and on light terminals,
this will likely be a dark color. The end result is that Rocket's
logging output should be readable everywhere.

Resolves #639.
2018-11-19 02:11:38 -08:00
Sergio Benitez 76c830a467 Update 'base64', 'crossbeam', 'rand' dependencies. 2018-11-18 03:47:12 -08:00
Sergio Benitez 3b6c4d2a5f Prefix codegen imports to avoid name collisions.
Fixes #817.
2018-11-12 13:08:39 -08:00
Sergio Benitez 834c91ae9d Remove the need for a current working directory.
This commit includes several breaking changes:

  * `Config{new,development,staging,production}` constructors return a
    `Config` instead of a `Result<Config>`.
  * `Config.root()` returns an `Option<&Path>` instead of `&Path`.
  * `ConfigError::BadCWD` was removed.
  * `Config` no longer exposes a `config_path` field.

Resolves #809.
2018-11-12 02:24:13 -08:00
Alva Snædís 4dea9eed36 Mention that u128, i128 implement UriDisplay. 2018-11-11 21:51:42 -08:00
Alva Snædís b87994b52c Implement FromParam, FromFormValue for i128, u128. 2018-11-11 21:51:24 -08:00
Sergio Benitez 4224419e63 Reduce 'cfg' usage for 'private-cookies' feature. 2018-11-08 23:56:15 -08:00
Linus Unnebäck 53758c6dd7 Introduce the 'private-cookies' feature. 2018-11-08 23:38:18 -08:00
Sergio Benitez b16269a30e Add note about cookie tracking serialization. 2018-11-08 21:40:42 -08:00
messense 64ba2056ef Use 'RwLock' to make 'Client' 'Sync'.
Resolves #814.
2018-11-08 21:40:34 -08:00
Alex Bowers 32e2ff4d6b Add ZIP (application/zip) as a known media type. 2018-11-08 20:47:26 -08:00
Sergio Benitez a2ada84986 Move 'UriDisplay' note to top of 'FromUriParam' docs. 2018-11-05 15:02:11 -08:00
Sergio Benitez 983ee9b32d Make inner 'LenientForm' field public. Add 'State::from()'. 2018-11-03 01:52:19 -07:00
Rukai b4f85daaf2 Make inner 'Form' field public. 2018-11-02 18:04:27 -07:00
Sergio Benitez 5762208bba Percent-encode characters: '[', ']', '\', '^', '|'.
Fixes #808.
2018-11-02 00:10:01 -07:00
Sergio Benitez 4dbd87a36f New version: 0.4.0-rc.1. 2018-10-31 14:35:30 -07:00
Sergio Benitez ef3e7ca2c6 Make all top-level crates publishable. 2018-10-31 03:57:37 -07:00
Sergio Benitez 41de1e62fb Implement 'Responder' for 'Status'.
This commit obviates the following removed types:

  * response::Failure
  * response::status::NoContent
  * response::status::Reset

Closes #489.
2018-10-31 03:57:22 -07:00
Sergio Benitez 16a65a9a45 Mention selective importing in 'rocket_codegen' docs. 2018-10-30 02:53:51 -07:00
jeb 328bf4b32e Support 'uri' macro in 2018 edition crates. 2018-10-30 02:44:22 -07:00
Sergio Benitez 4ef179cc59 Migrate from 'derive_utils' to published 'devise'.
Resolves #800.
2018-10-29 04:58:56 -07:00
Sergio Benitez 7090e2a1ee Use 'unreachable' to silence clippy on route codegen.
Closes #794.
2018-10-29 01:33:30 -07:00
Sergio Benitez 7b2b6aba81 Use published version of 'pear'. 2018-10-28 20:17:44 -07:00
Sergio Benitez c1b39a016b Improve 'Redirect' and 'rocket_codegen' documentation. 2018-10-28 20:17:44 -07:00
Sergio Benitez a77876f640 Use stable version of 'compiletest_rs'. 2018-10-28 20:17:44 -07:00
Sergio Benitez 3f2e724b23 Update rustls to 0.14. 2018-10-27 18:14:17 -07:00
Sergio Benitez 556206e8b3 Version all URLs to 'rocket.rs'. 2018-10-26 21:20:12 -07:00
Sergio Benitez 3798cd3e65 Document and test 'UriDisplay', its derive, and 'Formatter'. 2018-10-25 02:53:04 -07:00
Divyahans Gupta cda4c520f1 Add derive for 'UriDisplay'. 2018-10-24 22:14:12 -07:00
Divyahans Gupta 34421f13f3 Allow nested values in 'UriDisplay'. 2018-10-24 21:57:53 -07:00
Sergio Benitez 26db5ecb4e Fix normalization and Windows issues. 2018-10-24 00:01:56 -07:00
Sergio Benitez f6325798b1 Normalize paths in 'route_guard' test. 2018-10-23 01:23:11 -07:00
Sergio Benitez 9ef0b731c8 Rename 'codegen_next' to 'codegen'. 2018-10-22 00:01:41 -07:00
Sergio Benitez 8b2ee5b99a Point 'FromData' implementors to 'FromDataSimple'. 2018-10-21 23:43:24 -07:00
Sergio Benitez b429063279 Fix incorrect 'Data' buffering.
This regression was introduced in ad0ba0d5, where the buffer was
being copied from Hyper instead of being 'taken', resulting in
double-bufferred contents.
2018-10-21 20:36:40 -07:00
Sergio Benitez 2845b8d4d4 Add coloring disabling with 'ROCKET_CLI_COLORS=off'.
Resolves #703.
2018-10-21 19:46:37 -07:00
Sergio Benitez 831d8dfbe3 Document codegen attributes individually. 2018-10-18 04:00:36 -07:00
Sergio Benitez 330390ad71 Fix unsynchronized doctest. 2018-10-17 18:33:08 -07:00
Sergio Benitez ea158d4344 Individually document proc bang macros and derives. 2018-10-15 15:27:47 -07:00
Sergio Benitez ad0ba0d5f1 Remove use of 'unsafe' in 'Data'. 2018-10-15 01:52:06 -07:00
Sergio Benitez 05eee14d90 Update pear to latest revision. 2018-10-14 23:49:02 -07:00
Richo Healey 085a143075 Update docstring for 'ConfigBuilder::keep_alive'. 2018-10-11 16:39:35 -07:00
Sergio Benitez e34b2f3703 Fully document all public items in core. 2018-10-10 05:28:01 -07:00
Sergio Benitez 8b1e93192e Version documentation. 2018-10-09 04:31:09 -07:00
Sergio Benitez 28f2a33abd Use inter/intra-crate links in all documentation. 2018-10-09 04:31:09 -07:00
Sergio Benitez 2839aca8ce Update features for latest nightly. 2018-10-09 04:31:09 -07:00
Sergio Benitez 360b0e80b0 Port all codegen tests to codegen_next. 2018-10-09 04:31:08 -07:00
Sergio Benitez b9bf1ee37d Fix typed URI generation for query reform. 2018-10-09 04:31:08 -07:00
Sergio Benitez 61f107f550 Reimplement route attribute as a proc-macro.
This commits also implement the query reform from #608. It also consists
of many, many breaking changes. Among them are:

  * Query parts in route paths use new query reform syntax.
  * Routing for queries is now lenient.
    - Default ranking has changed to reflect query reform.
  * Format routing matching has been fixed.
    - Routes with formats matching "accept" will always collide.
    - Routes with formats matching "content-type" require requests to
      have an equivalent content-type header to match.
    - Requests with imprecise content-types are treated as not having a
      content-type.
  * Generated routes and catchers respect visibility modifiers.
  * Raw getter methods from request were renamed and retooled.
    - In particular, the index parameter is based on segments in the
      route path, not dynamic parameters.
  * The method-based attributes no longer accept a keyed 'path'.
  * The 'rocket_codegen' crate is gone and will no longer be public.
  * The 'FormItems' iterator emits values of type 'FormItem'.
    - The internal form items' string can no longer be retrieved.
  * In general, routes are more strictly validated.
  * Logging from codegen now funnels through logging infrastructure.
  * Routing has been optimized by caching routing metadata.

Resolves #93.
Resolves #608.
Resolves #693.
Resolves #476.
2018-10-09 04:18:04 -07:00
Sergio Benitez 3eb873d89d Tidy 'uri!' proc-macro. Improve error reporting. 2018-10-04 02:00:04 -07:00
jeb 7624aaf3e4 Reimplement 'uri!' as a proc-macro. 2018-10-03 21:56:37 -07:00
Sergio Benitez cee2f4439f Fix 'content_types' example for debug-only 'FromData' impl. 2018-09-27 01:16:26 -07:00
Sergio Benitez ec4cc3a293 Allow transforms in 'FromData'. Add 'FromDataSimple'.
The new 'FromData' trait allows an implementor to instruct the caller to
maintain state on its stack and later pass a borrow for processing.
Among other things, it greatly simplifies the 'Form' type, removing a
use of unsafe, and allows references in deserialized data guards.
2018-09-26 21:33:02 -07:00
Sergio Benitez 633d37bc97 Fix invalid TOML test for updated 'toml' dependency. 2018-09-25 19:41:59 -07:00
Sergio Benitez 24ee97575b Remove Collider trait. 2018-09-24 19:44:38 -07:00
Sergio Benitez 1a3fd1d237 Add known media types and extensions.
Adds the following to the list of known media types:

  * audio/webm (WEBA)
  * image/tiff (TIFF)
  * audio/aac (AAC)
  * text/calendar (Calendar)
  * video/mpeg (MPEG)
  * application/x-tar (TAR)
  * application/gzip (GZIP)
  * video/quicktime (MOV)
  * video/mp4 (MP4)

Also adds the following to the list of known extensions:

  * .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)
2018-09-18 18:25:39 -07:00
Sergio Benitez d011cd63fc Remove unnecessary 'use rocket::catch'. 2018-09-16 20:52:07 -07:00
Sergio Benitez 7926ffd6f0 Tidy 'routes!' and 'catchers!' proc-macros. 2018-09-16 20:38:02 -07:00
jeb 8e779610c4 Reimplement 'routes!' and 'catchers!' as proc-macros. 2018-09-16 18:52:23 -07:00
Sergio Benitez 46afabdfea Remove neglected and obscure 'Error' type. 2018-09-16 03:07:50 -07:00
Sergio Benitez 351757c6ee Rename 'Rocket::catch()' to 'Rocket::register()'. 2018-09-16 02:25:12 -07:00
Sergio Benitez 112e700836 Reimplement 'catch' attribute as a proc-macro. 2018-09-16 01:32:40 -07:00
Sergio Benitez 1f2f38ea5f Update to latest 'derive_utils'. 2018-09-14 23:15:58 -07:00
jeb cfdb2a404b Add Icon (image/x-icon) as a known media type. 2018-09-11 15:16:06 -07:00
jeb 242b358e37 Fix typo in 'handle_error' docstring. 2018-09-11 15:13:20 -07:00
Tal 8172f748b3 Implement 'Clone' for all URI types. 2018-09-03 19:42:34 -07:00
jeb 1da506ea5d Remove use of the 'const_fn' feature. 2018-09-03 19:41:31 -07:00
Sergio Benitez 42361c31f1 Use crates.io version of 'compiletest_rs'. 2018-08-26 19:24:13 -07:00
Sergio Benitez df0b96d3fa Remove 'attr_literals' feature: stabilized. 2018-08-26 19:18:49 -07:00
jeb 59e9f7fcc9 Update codegen for 2018-08-23 nightly. 2018-08-24 00:40:56 -06:00
Sergio Benitez fd6d577158 Remove 'use_extern_macros' feature: stabilized. 2018-08-18 17:06:28 -07:00
Sergio Benitez 7b4747ff1c Fix 'Segments::into_path_buf()' docstring. 2018-08-17 11:14:45 -07:00
Sergio Benitez fe9fad339e Clean up connection pooling documentation. 2018-08-15 23:31:49 -07:00
Eric Dattore 60b9f06407 Implement connection pooling support in contrib.
Resolves #167.
2018-08-15 22:11:53 -07:00
Sergio Benitez 01a5011b61 Add a module-level docstring to 'http'. 2018-08-15 19:55:34 -07:00
Sergio Benitez b642e94a2c Reduce or consolidate git-based dependencies. 2018-08-15 19:44:35 -07:00
messense 135b7d29ae Update codegen for 2018-08-14 nightly. 2018-08-14 22:01:33 -07:00
Sergio Benitez 10f267a56d Add 'ConfigError::Missing' to identify missing config keys. 2018-08-14 10:31:54 -07:00
Sergio Benitez e0961e0750 Require all 'AdHoc' fairings to be named. 2018-08-14 09:14:06 -07:00
messense 589743579a Fix benchmark compilation. 2018-08-13 15:51:42 -07:00
Sergio Benitez 651c202060 Move 'SegmentError' into 'uri' module. 2018-08-13 02:14:16 -07:00
Sergio Benitez 948a9e6720 Move 'Request::local_cache()' method for nicer docs. 2018-08-13 02:14:16 -07:00
Sergio Benitez 7abfaafcf9 Emit a helpful error when 'LocalRequest' is malformed. 2018-08-13 02:14:16 -07:00
Sergio Benitez 4010a967a6 Allow any 'T: Into<Vec<Route>>' to be mounted. 2018-08-13 02:14:12 -07:00
Sergio Benitez 29c9cffdbe Implement dynamic request handling via 'Handler' trait. 2018-08-12 02:13:42 -07:00
Sean Stangl 9bf585496c Apply more Clippy suggestions. 2018-08-11 23:41:35 -07:00
Ryan 995603666f Force close only the read end of connections.
Previously, when a request's body data exceeded the expected length,
Rocket would shutdown both ends of the corresponding connection. This PR
changes the behavior so that only the read end of the connection, on
Rocket's side, is shutdown. This allows a response to be sent in the
future while still preventing DoS attacks due to exuberant data.

Fixes #386.
2018-08-11 23:10:13 -07:00
Sergio Benitez 83cead775f Fix 'Error' associated type for 'Result<T, T::Error>'. 2018-08-10 19:14:39 -07:00
Sergio Benitez fe59a7fe38 Use better types for 'Error' associated types. 2018-08-10 04:42:30 -07:00
kryptan d9bfc9b104 Implement 'Responder' for '&[u8]'. 2018-08-07 23:58:54 -07:00
Sergio Benitez 41f0614b14 Update request-local state documentation. 2018-08-07 23:16:16 -07:00
jeb d1cfdbaa8e Add documentation and examples for request-local state.
Closes #654.
2018-08-07 19:40:30 -07:00
Marc Mettke cd776d5b6a Add 'and_then', 'failure_then', and 'forward_then' methods to 'Outcome'. 2018-08-07 18:55:04 -06:00
Sergio Benitez d7f6d82fe4 Implement 'FromForm[Value]', 'Responder' proc-macro derives.
This completes the migration of custom derives to proc-macros, removing
the need for the `custom_derive` feature in consumer code. This commit
also includes documentation, unit tests, and compile UI tests for each
of the derives.

Additionally, this commit improves the existing `FromForm` and
`FromFormValue` derives. The generated code for `FromForm` now returns
an error value indicating the error condition. The `FromFormValue`
derive now accepts a `form` attribute on variants for specifying the
exact value string to match against.

Closes #590.
Closes #670.
2018-08-06 19:58:07 -07:00
Sergio Benitez b0f86dcba0 Fix URI normalization checks in 'Rocket::mount()'. 2018-07-29 18:40:24 -07:00
Sergio Benitez 56c6a96f6a Overhaul URI types.
This is fairly large commit with several entangled logical changes.

The primary change in this commit is to completely overhaul how URI
handling in Rocket works. Prior to this commit, the `Uri` type acted as
an origin API. Its parser was minimal and lenient, allowing URIs that
were invalid according to RFC 7230. By contrast, the new `Uri` type
brings with it a strict RFC 7230 compliant parser. The `Uri` type now
represents any kind of valid URI, not simply `Origin` types. Three new
URI types were introduced:

  * `Origin` - represents valid origin URIs
  * `Absolute` - represents valid absolute URIs
  * `Authority` - represents valid authority URIs

The `Origin` type replaces `Uri` in many cases:

  * As fields and method inputs of `Route`
  * The `&Uri` request guard is now `&Origin`
  * The `uri!` macro produces an `Origin` instead of a `Uri`

The strict nature of URI parsing cascaded into the following changes:

  * Several `Route` methods now `panic!` on invalid URIs
  * The `Rocket::mount()` method is (correctly) stricter with URIs
  * The `Redirect` constructors take a `TryInto<Uri>` type
  * Dispatching of a `LocalRequest` correctly validates URIs

Overall, URIs are now properly and uniformly handled throughout Rocket's
codebase, resulting in a more reliable and correct system.

In addition to these URI changes, the following changes are also part of
this commit:

  * The `LocalRequest::cloned_dispatch()` method was removed in favor of
    chaining `.clone().dispatch()`.
  * The entire Rocket codebase uses `crate` instead of `pub(crate)` as a
    visibility modifier.
  * Rocket uses the `crate_visibility_modifier` and `try_from` features.

A note on unsafety: this commit introduces many uses of `unsafe` in the
URI parser. All of these uses are a result of unsafely transforming byte
slices (`&[u8]` or similar) into strings (`&str`). The parser ensures
that these casts are safe, but of course, we must label their use
`unsafe`. The parser was written to be as generic and efficient as
possible and thus can parse directly from byte sources. Rocket, however,
does not make use of this fact and so would be able to remove all uses
of `unsafe` by parsing from an existing `&str`. This should be
considered in the future.

Fixes #443.
Resolves #263.
2018-07-29 00:17:33 -07:00
Sergio Benitez c04655f290 Remove unnecessary code in codegen_next. 2018-07-27 21:03:33 -07:00
jeb 706cd32053 Use absolute paths in 'FromFormValue' derive.
This resolves a warning introduced in rust-lang/rust#51952 that will
eventually become a hard error, the latter of which is being tracked
in rust-lang/rust#50504.
2018-07-25 15:55:41 -07:00
Sean Stangl a7cc5542ab Fix various clippy warnings in core and codegen. 2018-07-25 15:28:35 -07:00
Sergio Benitez aaad4f5c57 Remove use of 'unsafe' in 'Fairings'. 2018-07-22 22:00:20 -07:00
Sergio Benitez cee3bbca30 Use git version of compiletest while release is broken. 2018-07-22 21:59:40 -07:00
Sergio Benitez e25a82b14b Update dependencies for ring 0.13. 2018-07-22 21:59:40 -07:00
jeb 0c80217289 Fix various spelling and grammar issues in core and contrib. 2018-07-20 22:14:58 -06:00
Sergio Benitez 19d8569cdb Update core, codegen for 2018-07-16 nightly. 2018-07-17 14:06:32 -07:00
Sergio Benitez 9c7b868371 Update codegen for 2018-07-15 nightly. 2018-07-16 14:30:20 -07:00
Sergio Benitez 18a91c938e Reexport 'cookie::SameSite' from the http module. 2018-07-10 17:09:24 -07:00
Sergio Benitez 5e2502f028 Add leading underscore to avoid unused warning. 2018-07-07 19:10:50 -07:00
Sergio Benitez 69683dddd7 Mask emoji in the 'catchers' info log. 2018-07-07 19:01:00 -07:00
Sergio Benitez 351b8f7c37 Small fixes to request-local state cache implementation. 2018-07-07 18:52:03 -07:00
Ville Hakulinen 97c6b3ace8 Implement Request-Local State Cache.
Resolves #654.
2018-07-07 18:41:21 -07:00
Sergio Benitez 036e4b621c Note that the 'log' config accepts "off" in rustdocs. 2018-07-07 18:30:10 -07:00
Beatriz Rizental 965c90afc9 Add 'log = off' config option to disable all logging. 2018-07-07 18:12:25 -07:00
Sergio Benitez 7b4b0646c5 Don't color logs on Windows if enabling ASCII escapes fails. 2018-07-05 17:54:19 -07:00
Sergio Benitez bd6cdecf00 Improve 'Config::set_raw_tls()' implementation. 2018-07-02 20:02:23 -07:00
Sergio Benitez ce8817dd3c Clarify behavior of 'Rocket::attach()'. 2018-07-02 18:18:41 -07:00
Imron Alston a383d49ab0 Add FLAC (audio/flac) as a known media type. 2018-06-28 19:42:59 -07:00
jeb 648eb1a5eb Prefix 'uri!' format args to allow ignored parameters. 2018-06-25 11:24:59 -07:00
Sergio Benitez 3413129296 Small fixes to code comments. 2018-06-25 11:21:02 -07:00
jeb 5b8f8eebc6 Update codegen for 2018-06-22 nightly (2/2). 2018-06-22 23:49:22 -07:00
Sergio Benitez 69c953edc9 Update codegen for 2018-06-22 nightly (1/2). 2018-06-22 23:46:42 -07:00
Sergio Benitez 64bbed1422 Improve documentation on unsafe usage.
All uses of `unsafe` are now thoroughly documented with arguments and
informal proofs of correctness as well as conditions that must hold for
these arguments to pass.

This commit also reduces the number of `unsafe` uses by 7, bringing the
count to ~10 non-test uses of `unsafe`.
2018-06-20 14:02:12 +02:00
Sergio Benitez df7111143e Split the 'http' module into its own 'rocket_http' crate. 2018-06-07 15:34:47 +02:00
Sergio Benitez 900e716ea6 Update to Pear 0.1. 2018-06-04 18:06:08 +02:00
Sergio Benitez 1e8e4cc553 Fix Cargo.toml path to README. 2018-06-03 19:39:32 +02:00
Sergio Benitez f171dc9d09 Reorganize repository.
The directory structure has changed to better isolate crates serving
core and contrib. The new directory structure is:

  contrib/
    lib/ - the contrib library
  core/
    lib/ - the core Rocket library
    codegen/ - the "compile extension" codegen library
    codegen_next/ - the new proc-macro library
  examples/ - unchanged
  scripts/ - unchanged
  site/ - unchanged

This commit also removes the following files:

  appveyor.yml - AppVeyor (Rust on Windows) is far too spotty for use
  rustfmt.toml - rustfmt is, unfortunately, not mature enough for use

Finally, all example Cargo crates were marked with 'publish = false'.
2018-06-03 18:44:38 +02:00