Skip to content

Commit

Permalink
Merge branch 'master' into modify-fairings
Browse files Browse the repository at this point in the history
  • Loading branch information
the10thWiz committed Aug 14, 2023
2 parents d41943e + ddeac5d commit 55aeb82
Show file tree
Hide file tree
Showing 247 changed files with 8,175 additions and 3,282 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ blank_issues_enabled: true
contact_links:
- name: Question
url: https://github.com/SergioBenitez/Rocket/discussions
about: Please ask questions or raise indefinite concerns on Dicussions
about: Please ask questions or raise indefinite concerns on Discussions
60 changes: 45 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ on: [push, pull_request]
env:
CARGO_TERM_COLOR: always


jobs:
test:
name: "${{ matrix.platform.name }} ${{ matrix.test.name }} (${{ matrix.platform.toolchain }})"
runs-on: ${{ matrix.platform.distro }}

strategy:
fail-fast: false
matrix:
fallible: [false]
platform:
- { name: Linux, distro: ubuntu-latest, toolchain: stable }
- { name: Windows, distro: windows-latest, toolchain: stable }
Expand All @@ -27,16 +28,34 @@ jobs:
test: { name: Core, flag: "--core" }
- platform: { name: Linux, distro: ubuntu-latest, toolchain: stable }
test: { name: Release, flag: "--release" }

runs-on: ${{ matrix.platform.distro }}

continue-on-error: ${{ matrix.platform.name == 'Linux'
&& matrix.platform.toolchain == 'nightly'
&& matrix.test.name == 'Debug' }}
- platform: { name: Linux, distro: ubuntu-latest, toolchain: stable }
test: { name: UI, flag: "--ui" }
fallible: true
- platform: { name: Linux, distro: ubuntu-latest, toolchain: nightly }
test: { name: UI, flag: "--ui" }
fallible: true
- platform: { name: Windows }
working-directory: "C:\\a\\${{ github.event.repository.name }}\\${{ github.event.repository.name }}"

steps:
- name: Checkout Sources
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Free Disk Space (Linux)
if: matrix.platform.name == 'Linux'
run: |
echo "Freeing up disk space on Linux CI"
df -h
sudo rm -rf /usr/share/dotnet/
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo rm -rf /usr/local/graalvm/
sudo rm -rf /usr/local/.ghcup/
sudo rm -rf /usr/local/share/powershell
sudo rm -rf /usr/local/share/chromium
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/local/lib/node_modules
df -h
- name: Install Native Dependencies (macOS)
if: matrix.platform.name == 'macOS'
Expand Down Expand Up @@ -64,24 +83,35 @@ jobs:
sudo apt-get install -y libmysqlclient-dev libpq-dev libsqlite3-dev
- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@master
id: toolchain
with:
profile: minimal
toolchain: ${{ matrix.platform.toolchain }}
override: true
components: rust-src

- name: Cache Example Workspace
if: matrix.test.name == 'Examples'
uses: Swatinem/rust-cache@v1
uses: Swatinem/rust-cache@v2
with:
working-directory: "examples"
workspaces: examples
key: ${{ matrix.test.name }}-${{ steps.toolchain.outputs.cachekey }}

- name: Cache Root Workspace
if: matrix.test.name != 'Examples'
uses: Swatinem/rust-cache@v1
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.test.name }}
key: ${{ matrix.test.name }}-${{ steps.toolchain.outputs.cachekey }}

# Don't run out of disk space on Windows. C: has much much space than D:.
- name: Switch Disk (Windows)
if: matrix.platform.name == 'Windows'
run: |
Get-PSDrive
cp D:\a C:\ -Recurse
Get-PSDrive
- name: Run Tests
continue-on-error: ${{ matrix.fallible }}
working-directory: ${{ matrix.working-directory || github.workspace }}
run: ./scripts/test.sh ${{ matrix.test.flag }} -q
shell: bash
82 changes: 80 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,81 @@
# Version 0.5.0-rc.3 (Mar 23, 2023)

## Major Features and Improvements

* Added a [`max_blocking`] configuration parameter.

The parameter sets a limit on the number of threads used by blocking tasks.

* Added an [`ip_header`] "real IP" header configuration parameter.

The parameter allows modifying the header that Rocket attempts to use to retrieve the "real IP"
address of the client via `Request` methods like [`Request::client_ip()`]. Additionally, the
change allows disabling the use of any such header entirely.

* A [`pool()`] method is emitted by [`rocket_sync_db_pools`] for code-generated pools.

The method returns an opaque reference to a type that can be used to retrieve pooled connections
outside of a request handling context.

* Raw binary form field data can be retrieved using the `&[u8]` form guard.

* Data guards are now eligible [sentinels].

## General Improvements

* Final launch messages are now _always_ logged, irrespective of profile.
* Only functions that return `Rocket<Build>` are now `#[must_use]`, not all `Rocket<P>`.
* Fixed mismatched form field names in errors under certain conditions in [`FromForm`] derive.
* The [`FromForm`] derive now collects _all_ errors that occur.
* Data pools are now gracefully shutdown in [`rocket_sync_db_pools`].
* Added [`Metadata::render()`] in [`rocket_dyn_templates`] for direct template rendering.
* Rocket salvages more information from malformed requests for error catchers.
* The `cookie` `secure` feature is now properly conditionally enabled.
* Data before encapsulation boundaries in TLS keys is allowed and ignored.
* Support for TLS keys in SEC1 format was added.
* Rocket now warns when a known secret key is configured.
* A panic that could occur on shutdown in `rocket_sync_db_pools` was fixed.

### Known Media Types

- Added `MP3`: `audio/mpeg`.
- Added `CBZ`: `application/vnd.comicbook+zip`, extension `.cbz`.
- Added `CBR`: `application/vnd.comicbook-rar`, extension `.cbr`.
- Added `RAR`: `application/vnd.rar`, extension `.rar`.
- Added `EPUB`: `application/epub+zip`, extension `.epub`.
- Added `OPF`: `application/oebps-package+xml`, extension `.opf`.
- Added `XHTML`: `application/xhtml+xml`, extension `.xhtml`.

### Trait Implementations

* Implemented `Responder` for `Box<T: Responder + Sized>`.
* Implemented `FromForm` for `Arc<T>`.
* Implemented `Fairing` for `Arc<dyn Fairing>`.

### Updated Dependencies

* Updated `syn` to `2`.
* Updated `diesel` to `2.0`.
* Updated `sqlx` to `0.6`.
* Updated `notify` to `5.0`.
* Updated `criterion` to `0.4`.
* Updated `deadpool-redis` to `0.11`.
* Updated `normpath` from to `1`.
* Updated `cookie` to `0.17`.
* Replaced `atty` with `is-terminal`.

## Infrastructure

* UI tests are now allowed to fail by the CI to avoid false negatives.
* Fixed many typos, errors, and broken links throughout docs and examples.
* The GitHub CI workflow was updated to use maintained actions.

[`Metadata::render()`]: https://api.rocket.rs/v0.5-rc/rocket_dyn_templates/struct.Metadata.html#method.render
[`pool()`]: https://api.rocket.rs/v0.5-rc/rocket_sync_db_pools/example/struct.ExampleDb.html#method.pool
[`Request::client_ip()`]: https://api.rocket.rs/v0.5-rc/rocket/request/struct.Request.html#method.client_ip
[`max_blocking`]: https://api.rocket.rs/v0.5-rc/rocket/struct.Config.html#structfield.max_blocking
[`ip_header`]: https://api.rocket.rs/v0.5-rc/rocket/struct.Config.html#structfield.ip_header

# Version 0.5.0-rc.2 (May 09, 2022)

## Major Features and Improvements
Expand Down Expand Up @@ -69,7 +147,7 @@
* Rocket now uses the 2021 edition of Rust.

[`(ContentType, T)`]: https://api.rocket.rs/v0.5-rc/rocket/response/content/index.html#usage
[v0.4 to v0.5 migration guide]: https://rocket.rs/v0.5-rc/guide/upgrading-from-0.4/
[v0.4 to v0.5 migration guide]: https://rocket.rs/v0.5-rc/guide/upgrading/
[FAQ]: https://rocket.rs/v0.5-rc/guide/faq/
[`Rocket::launch()`]: https://api.rocket.rs/v0.5-rc/rocket/struct.Rocket.html#method.launch
[`ErrorKind::Shutdown`]: https://api.rocket.rs/v0.5-rc/rocket/error/enum.ErrorKind.html#variant.Shutdown
Expand Down Expand Up @@ -2168,7 +2246,7 @@ the Rocket APIs. They are summarized through the following API changes:
* Added `FromData` conversion trait and default implementation.
* `FromData` is used to automatically derive the `data` parameter.
* `Responder`s are now final: they cannot forward to other requests.
* `Responser`s may only forward to catchers.
* `Responder`s may only forward to catchers.

## Breaking

Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
members = [
"core/lib/",
"core/codegen/",
Expand All @@ -8,5 +9,6 @@ members = [
"contrib/sync_db_pools/codegen/",
"contrib/sync_db_pools/lib/",
"contrib/dyn_templates/",
"contrib/ws/",
"site/tests",
]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ suite with `TRYBUILD=overwrite` and inspect the `diff` of `.std*` files.

[`trybuild`]: https://docs.rs/trybuild/1

## Documentation
### API Docs

API documentation is built with `./scripts/mk-docs.sh`. The resulting assets are
uploaded to [api.rocket.rs](https://api.rocket.rs/).
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ harness = false

[dev-dependencies]
rocket = { path = "../core/lib/" }
criterion = "0.3"
criterion = "0.4"
4 changes: 2 additions & 2 deletions benchmarks/src/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ fn generate_matching_requests<'c>(client: &'c Client, routes: &[Route]) -> Vec<L
}

fn request_for_route<'c>(client: &'c Client, route: &Route) -> LocalRequest<'c> {
let path = route.uri.origin.path()
let path = route.uri.path()
.raw_segments()
.map(staticify_segment)
.collect::<Vec<_>>()
.join("/");

let query = route.uri.origin.query()
let query = route.uri.query()
.map(|q| q.raw_segments())
.into_iter()
.flatten()
Expand Down
2 changes: 1 addition & 1 deletion contrib/db_pools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ full usage details.

```toml
[dependencies.rocket_db_pools]
version = "0.1.0-rc.2"
version = "=0.1.0-rc.3"
features = ["sqlx_sqlite"]
```

Expand Down
4 changes: 2 additions & 2 deletions contrib/db_pools/codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rocket_db_pools_codegen"
version = "0.1.0-rc.2"
version = "0.1.0-rc.3"
authors = ["Sergio Benitez <sb@sergio.bz>", "Jeb Rosen <jeb@jebrosen.com>"]
description = "Procedural macros for rocket_db_pools."
repository = "https://github.com/SergioBenitez/Rocket/contrib/db_pools"
Expand All @@ -14,7 +14,7 @@ rust-version = "1.56"
proc-macro = true

[dependencies]
devise = "0.3"
devise = "0.4"
quote = "1"

[dev-dependencies]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
error[E0277]: the trait bound `Unknown: Pool` is not satisfied
--> tests/ui-fail-nightly/database-types.rs:7:10
|
7 | struct A(Unknown);
| ^^^^^^^ the trait `Pool` is not implemented for `Unknown`
|
= help: the trait `Pool` is implemented for `deadpool::managed::Pool<M, C>`
--> tests/ui-fail-nightly/database-types.rs:7:10
|
7 | struct A(Unknown);
| ^^^^^^^ the trait `Pool` is not implemented for `Unknown`
|
= help: the trait `Pool` is implemented for `deadpool::managed::Pool<M, C>`
note: required by a bound in `rocket_db_pools::Database::Pool`
--> $WORKSPACE/contrib/db_pools/lib/src/database.rs
|
| type Pool: Pool;
| ^^^^ required by this bound in `rocket_db_pools::Database::Pool`
--> $WORKSPACE/contrib/db_pools/lib/src/database.rs
|
| type Pool: Pool;
| ^^^^ required by this bound in `Database::Pool`

error[E0277]: the trait bound `Vec<i32>: Pool` is not satisfied
--> tests/ui-fail-nightly/database-types.rs:11:10
Expand All @@ -22,4 +22,4 @@ note: required by a bound in `rocket_db_pools::Database::Pool`
--> $WORKSPACE/contrib/db_pools/lib/src/database.rs
|
| type Pool: Pool;
| ^^^^ required by this bound in `rocket_db_pools::Database::Pool`
| ^^^^ required by this bound in `Database::Pool`
22 changes: 12 additions & 10 deletions contrib/db_pools/codegen/tests/ui-fail-stable/database-types.stderr
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
error[E0277]: the trait bound `Unknown: Pool` is not satisfied
--> tests/ui-fail-stable/database-types.rs:7:10
|
7 | struct A(Unknown);
| ^^^^^^^ the trait `Pool` is not implemented for `Unknown`
|
--> tests/ui-fail-stable/database-types.rs:7:10
|
7 | struct A(Unknown);
| ^^^^^^^ the trait `Pool` is not implemented for `Unknown`
|
= help: the trait `Pool` is implemented for `deadpool::managed::Pool<M, C>`
note: required by a bound in `rocket_db_pools::Database::Pool`
--> $WORKSPACE/contrib/db_pools/lib/src/database.rs
|
| type Pool: Pool;
| ^^^^ required by this bound in `rocket_db_pools::Database::Pool`
--> $WORKSPACE/contrib/db_pools/lib/src/database.rs
|
| type Pool: Pool;
| ^^^^ required by this bound in `Database::Pool`

error[E0277]: the trait bound `Vec<i32>: Pool` is not satisfied
--> tests/ui-fail-stable/database-types.rs:11:10
|
11 | struct B(Vec<i32>);
| ^^^^^^^^ the trait `Pool` is not implemented for `Vec<i32>`
|
= help: the trait `Pool` is implemented for `deadpool::managed::Pool<M, C>`
note: required by a bound in `rocket_db_pools::Database::Pool`
--> $WORKSPACE/contrib/db_pools/lib/src/database.rs
|
| type Pool: Pool;
| ^^^^ required by this bound in `rocket_db_pools::Database::Pool`
| ^^^^ required by this bound in `Database::Pool`
1 change: 1 addition & 0 deletions contrib/db_pools/codegen/tests/ui-fail.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#[test]
#[ignore]
fn ui() {
let path = match version_check::is_feature_flaggable() {
Some(true) => "ui-fail-nightly",
Expand Down
Loading

0 comments on commit 55aeb82

Please sign in to comment.