Pastebin example uses now deprecated `rand::gen()` which was changed due
to the reserved `gen` keyword in Rust 2024 edition.
Rather than changing dependencies or updating the guide to specify an
older edition, I've updated to use `gen_range` (should be best practice
to avoid an infinitesimal bias anyway). This should work with any
edition.
Also fixed typos I noticed in the CONTRIBUTING doc.
---------
Co-authored-by: Daniel Welsh <danielw2000@gmail.com>
Co-authored-by: Matthew Pomes <matthew.pomes@pm.me>
The `Sync` bound on `Pool` is, as far as I can tell, unneeded.
`diesel-async`'s mysql connection pool isn't `Sync` anymore,
which is why bound needed to be removed.
closes: #2969
Initialize db_pools without forcing immediate DB connections. Avoid
crashing at launch if the database is unavailable or misconfigured.
Why:
- Databases can be temporarily unavailable; servers shouldn't refuse
to start solely due to transient DB issues.
- Reduces false failed-deploy signals.
Effect:
- sqlx backend matches deadpool behavior: pool builds without dialing.
- Connection errors now surface when acquiring a connection
from the pool, not during fairing init.
- Update `gen_certs.sh`
- Generate client cert as well by default
- Set expiration to 10 years to match other certs
- Set subject to match expected values in testbench test
- Update testbench `mtls` to ignore key hash value, and only check issuer
and subject.
This commit introduces support for method-less routes and route
attributes, which match _any_ valid method: `#[route("/")]`. The `Route`
structure's `method` field is now accordingly of type `Option<Route>`.
The syntax for the `route` attribute has changed in a breaking manner.
To set a method, a key/value of `method = NAME` must be introduced:
```rust
#[route("/", method = GET)]
```
If the method's name is a valid identifier, it can be used without
quotes. Otherwise it must be quoted:
```rust
// `GET` is a valid identifier, but `VERSION-CONTROL` is not
#[route("/", method = "VERSION-CONTROL")]
```
Closes#2731.
This works-around an issue where hyper incorrectly removes the body on
204 responses without removing the content-length or setting it to zero.
Resolves#2821.
Introduces four new methods:
* `Rocket::fairing::<F>()`
* `Rocket::fairing_mut::<F>()`
* `Rocket::fairings::<F>()`
* `Rocket::fairings_mut::<F>()`
These methods allow retrieving references to fairings of type `F` from
an instance of `Rocket`. The `fairing` and `fairing_mut` methods return
a (mutable) reference to the first attached fairing of type `F`, while
the `fairings` and `fairings_mut` methods return an iterator over
(mutable) references to all attached fairings of type `F`.
Co-authored-by: Matthew Pomes <matthew.pomes@pm.me>
`PartialEq` when not derived results in `StructuralPartialEq` not being
implemented. As this was the case for `http::Status`, matching against
constants like `Status::Unauthorized` was not allowed.
This commit replaces the manual implementations of equality traits
(`PartialEq`, `Eq`) and ordering traits (`PartialOrd`, `Ord`) for
`http::Status` with `#[derive]`.
Resolves#2844.
Prior to this commit, connections from 'sync_db_pools' assumed that they
were being dropped in an async context. This is overwhelmingly the
common case as connections are typically dropped immediately after
request processing. Nothing requires this, however, so holding a
connection beyond the scope of the async context was possible (i.e. by
storing a connection in managed state). Given the connection's `Drop`
impl calls `spawn_blocking`, this resulted in a panic on drop.
This commit resolves the issue by modifying `Drop` so that it calls
`spawn_blocking` only when it is executing inside an async context. If
not, the connection is dropped normally, without `spawn_blocking`.
Also modifies the `databases` example so that it makes use of the new
ability to run migrations in diesel-async v0.5. To accomplish this,
`diesel_async::async_connection_wrapper::AsyncConnectionWrapper` is
exported from `rocket_db_pools::diesel` and used in the `diesel_mysql`
portion of the `databases` example. The URL for the MySQL version of the
database example is now `/mysql` instead of `/diesel-async`.
This commit enforces using 'MsgPack<T>', and not 'MsgPack<T, Foo>' or
'Compact<T>', to deserialize MsgPack-encoded data. It also simplifies
the round-trip msgpack test and removes the dev-dependency on `rmp`.
This commit improves the docs for the `FromParam` derive macro and
exposes a new `InvalidOption` error value, which is returned when the
derived `FromParam` implementation fails.