Commit Graph

2456 Commits

Author SHA1 Message Date
Daniel Welsh
3a54d079ae
Update pastebin example to avoid new gen reserved keyword; couple of typo fixes (#2975)
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>
2025-12-28 12:27:38 -06:00
Matthew Pomes
0f73a60cc0
Handle missing reuse parameter correctly
Actually check for missing key, since figment doesn't
properly decode `Option<bool>` on it's own.

closes: #2976
2025-12-28 00:35:54 -06:00
Dan Dumont
3d1de7bac5
Expose the SNI when possible. (#2943)
Grabs the SNI from TLS connections and saves to ConenctionMeta struct. Provides useful methods for exracting the SNI from requests.

Closes #2942
2025-12-27 22:35:44 -06:00
Matthew Pomes
3ccfd8bd77
Update diesel-async to 0.6, and remove an unnecessary Sync bound (#2972)
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
2025-12-27 21:47:16 -06:00
Sergio Benitez
504efef179 Fix upstream breakage in TLS example.
A breaking change in `tracing` (see tracing#3309) resulted in the TLS
example breaking. This commit implements the work-around in the issue.
2025-08-31 19:09:31 +02:00
Nikita Samusev
4a410b75a9 Link directly to GitHub repo in quickstart guide. 2025-08-31 18:39:36 +02:00
iota
6c6ef5d439 Fix typo in requests guide: 'once' -> 'one'. 2025-08-31 18:38:00 +02:00
Matthew Pomes
933a351fbb Fix new lifetime warnings.
Rust now warns when it determines that an elided lifetime has a name.
This commit updates relevant cases to use the named lifetime instead.
2025-08-31 18:38:00 +02:00
Matthew Pomes
2d4dc1c0ed Add 'Request::version()' to retrieve HTTP version.
- Populates value from hyper version.
- Also adds a method to override version for local requests.

Co-authored-by: Dan Dumont <dan.dumont@hcl.com>
2025-08-31 18:38:00 +02:00
Paul Adenot
bcc784de73 Fix copies in Dockerfile in deploying guide. 2025-08-31 18:37:54 +02:00
Dan Fego
ebea1d4238 Impl 'Default' for 'Config' to match docs. 2025-08-31 18:33:45 +02:00
Cormac Relf
1435f6574f Defer sqlx pool connect errors on startup.
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.
2025-08-31 18:29:59 +02:00
Matthew Pomes
86ae40d61b Fix testbench mTLS tests.
- 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.
2025-08-31 18:29:28 +02:00
Jonathan A. McCormick, Jr.
a607ede4df Fix typo in 12-pastebin.md: 'crate' -> 'create'. 2025-08-31 18:29:08 +02:00
Sergio Benitez
28891e8072 Update 'tokio-tungstenite' to 0.24, 'notify' to 7. 2024-12-02 11:55:57 +01:00
Sergio Benitez
4c232c7f74 Skip fuzzer check on Windows. 2024-12-02 11:49:14 +01:00
Tim McCormack
ea0a1af683 Improve 'RawStr' percent encoding doctests. 2024-12-02 11:15:46 +01:00
Sergio Benitez
f058f6e01d Fix error code in 'FromParam' rustdocs.
Resolves #2880.
2024-12-02 11:08:09 +01:00
Sergio Benitez
3fd5508629 Sync 's2n-quic-h3' to fix upstream bug. 2024-12-02 10:58:14 +01:00
Sergio Benitez
b453bd589b Revert unnecessary change for clippy. 2024-12-02 10:37:48 +01:00
sheshnath-at-knoldus
ebfcbd2c75
fixed clippy warnings 2024-11-17 14:31:50 -06:00
Tim McCormack
fd75d0ccca Fix minor typos in guide and docstring 2024-10-21 20:51:58 -04:00
Sergio Benitez
3bf9ef02d6 Update 's2n-quic-h3' to work-around upstream bug. 2024-09-02 20:27:27 -07:00
Azan Ali
de6632ea56 Improve wrapping responders guide section. 2024-08-28 10:47:20 -07:00
Sergio Benitez
72c91958b7 Support routes that match any method.
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.
2024-08-24 03:00:52 -07:00
Sergio Benitez
9496b70e8c Strip body and content-length on 204, body on 304.
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.
2024-08-23 16:18:48 -07:00
Sergio Benitez
d3323391ab Add fairing retrieval methods to 'Rocket'.
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>
2024-08-21 16:42:09 -07:00
Sergio Benitez
dbeba45b36 Fix testbench ignite test: match new log output. 2024-08-21 02:22:28 -07:00
Sergio Benitez
e889c2628a Improve ignite fairing failure trace message. 2024-08-20 23:32:04 -07:00
Wojciech Polak
8b9d906cc4 Derive equality, ordering traits for http::Status.
`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.
2024-08-19 15:52:44 -07:00
Sergio Benitez
327b1ad064 Allow sync drops for 'sync_db_pools' connections.
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`.
2024-08-18 20:03:01 -07:00
drawdrop
7fdcf2d1ed Fix various docstring typos.
* unqiue -> unique
  * overriden -> overridden
  * sentinal -> sentinel
2024-08-17 19:37:19 -07:00
Sergio Benitez
2dba18d6f2 Add CONTRIBUTING and update README accordingly. 2024-08-17 19:09:55 -07:00
Sergio Benitez
ef1cfa0965 Impl 'TryFrom<&str>' for 'Method'.
Also implements 'From<Infallible>' for 'ParseMethodError'.
2024-08-17 04:26:18 -07:00
lobsterwise
4c71ed6ee3 Fix support for HTTP extension methods. 2024-08-17 04:25:49 -07:00
Sergio Benitez
51d4ed4394 Update 'h3' and 's2n_quic' dependencies. 2024-08-16 16:12:12 -07:00
Sergio Benitez
faa0543c3d Pin 's2n-quic-h3' git dependency to a commit. 2024-08-16 15:47:04 -07:00
Sergio Benitez
2825e46a34 Update 'tokio-tungstenite' to 0.23. 2024-08-16 05:30:45 -07:00
Sergio Benitez
e41b5f469e Fix Windows CI: update vcpkg dependency bundle. 2024-08-16 02:24:20 -07:00
Sergio Benitez
6484c62132 Update 'memcache' to 0.17.
We no longer depend on 'r2d2-memcache', which was woefully out of date,
and instead implement our own r2d2 connection manager for memcache.
2024-08-14 18:39:20 -07:00
Sergio Benitez
39c90481e7 Update 'sqlx' to 0.8, 'rusqlite' to 0.31. 2024-08-14 18:39:17 -07:00
Sergio Benitez
628cc2a2f6 Update 'deadpool-{postgres,redis}' to 0.14, 0.16. 2024-08-14 18:39:17 -07:00
Sergio Benitez
87f80714fa Update 'diesel-async' in 'db_pools' to 0.5.
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`.
2024-08-14 18:36:56 -07:00
Matthew Pomes
1a3ef5b23f
Update docs to make sense 2024-08-10 13:02:41 -05:00
Sergio Benitez
39ed4a4909 Enforce using 'MsgPack<T>' to deserialize.
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`.
2024-08-09 23:10:33 -07:00
Sergio Benitez
0998b37aeb Add '--help' flag to testing script. 2024-08-09 22:22:25 -07:00
Matthew Pomes
db598be3a8
Change default, and use MsgPack in place of Named 2024-08-09 23:13:53 -05:00
Artemis
df71f79bd9
Allow responding with named MessagePack data.
Closes #2107
2024-08-09 23:13:52 -05:00
Sergio Benitez
1f82d4bbcd Improve FromParam derive docs and error values.
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.
2024-08-09 18:44:50 -07:00
Sergio Benitez
15062ded09 Update UI tests for latest rustc. 2024-08-09 18:34:59 -07:00