Commit Graph

849 Commits

Author SHA1 Message Date
Bill 002f13510c Remove double semicolon in SSE example 2024-05-22 20:31:19 -05:00
Sergio Benitez 2ef1e2f94b Update yansi to 1.0.1. 2024-05-22 20:31:19 -05:00
Sergio Benitez 29e7093ef4 Impl 'FromForm' for char, 'Range' types.
Implements 'FromForm' for:

  * `char`
  * `Range<T: FromForm>`
  * `RangeFrom<T: FromForm>`
  * `RangeTo<T: FromForm>`
  * `RangeToInclusive<T: FromForm>`

Resolves #2759.
2024-05-22 14:12:45 -05:00
Sergio Benitez 4c483dcea9 Improve 'sync_db_pools' codegen. Update UI tests. 2024-05-22 13:44:45 -05:00
Sergio Benitez dfc118f279 Use call site hygiene in FromForm derive.
This commit changes the `FromForm` derive codegen so that it
consistently emits tokens with call site hygiene. This allows `FromForm`
derives to be emitted my macros more reliably.
2024-05-22 13:43:53 -05:00
Łukasz Wojniłowicz ae439fae54 Symlink license files in all crate directories.
Resolves #2760.
2024-05-22 13:41:37 -05:00
Sergio Benitez 5398dfb34e Allow displaying [T; N], Vec<T>, [u8] via 'uri!'.
Resolves #2750.
2024-05-22 13:35:48 -05:00
Sergio Benitez cacd4578a2 Fix incorrect 'Accept' swap in rustdocs.
Resolves #2743.
2024-05-22 13:29:55 -05:00
Sergio Benitez e493be8d3c Forward whole-form errors in 'FromForm' derive.
Resolves #2672.
2024-01-17 21:53:12 -08:00
Sergio Benitez 82362b1350 Upgrade 'smallvec' to simplify 'Accept' impl. 2024-01-17 21:53:12 -08:00
Sergio Benitez b10702bf20 Remove custom 'docify!' macro: use '#[doc]`. 2024-01-17 21:53:12 -08:00
Paul Lietar 52de9a1fa6 Ensure 'TempFile' flushes when persisted.
Tokio's `File::write_all()` method has an unexpected quirk: it doesn't
actually write all the requested content to the file when the returned
future resolves. Instead, the write is attempted and queued. This means
that the `persist()` method can resolve without the data being persisted
to the file system. Subsequent reads of the ostensibly written-to file
can thus fail to contain the expected data.

An call to `flush()` following `write_all()` would circumvent the issue.
Alternatively, calling `fs::write()` actually writes to the file system
before returning and requires fewer lines of code. This commit thus
swaps the call to `write_all()` with `fs::write()`.
2024-01-17 21:53:12 -08:00
Martyn 61e77c5e13 Document "reconnect ad-infinitum" SSE pitfall. 2024-01-17 21:53:12 -08:00
Sergio Benitez f2730fb509 Fix min dependency versions. Update MSRV to 1.64.
Also includes a work-around for a buggy `format_args!` macro found in
rustc 1.67 and 1.68.

Resolves #2670.
2024-01-17 21:42:08 -08:00
Sergio Benitez 2ce7545f7e Silence more warnings in generated code. 2023-12-05 17:29:30 -08:00
Sergio Benitez ab82064354 Update 'SergioBenitez/Rocket' to 'rwf2/Rocket'.
Resolves rwf2/rwf2#5.
2023-11-22 21:41:51 +01:00
Sergio Benitez 38ae8d6317 Update version numbers for 0.5.0. 2023-11-17 16:38:14 +01:00
Sergio Benitez c06a51bd37 Fix typos.
Co-authored-by: cui fliter <imcusg@gmail.com>
2023-11-17 16:38:14 +01:00
Sergio Benitez 3ee6e5c758 New version: 0.5.0-rc.4.
New contrib versions: 0.1.0-rc.4.
2023-11-17 16:38:14 +01:00
Sergio Benitez 2ae91b9c9e Update UI tests. 2023-11-01 18:56:48 -05:00
Sergio Benitez 11fed5a466 Document '&[u8]' form/data guard, limits. 2023-11-01 18:56:48 -05:00
Sergio Benitez 654b1c3c79 Set 'SameSite' to 'Lax' on removal cookies.
This avoids needless warnings from certain browsers.
2023-11-01 18:50:58 -05:00
Sergio Benitez df3a4e0dca Qualm various emerging unused warnings. 2023-11-01 18:50:58 -05:00
Sergio Benitez 186ec84f5b Improve forwarding status code precision.
Previously, the `NotFound` status code was used to signal many kinds of
recoverable, forwarding errors. This included validation errors, incorrect
Content-Type errors, and more.

This commit modifies the status code used to forward in these instances to more
precisely indicate the forwarding condition. In particular:

  * Parameter `FromParam` errors now forward as 422 (`UnprocessableEntity`).
  * Query paramater errors now forward as 422 (`UnprocessableEntity`).
  * Use of incorrect form content-type forwards as 413 (`UnsupportedMediaType`).
  * `WebSocket` guard now forwards as 400 (`BadRequest`).
  * `&Host`, `&Accept`, `&ContentType`, `IpAddr`, and `SocketAddr` all forward
    with a 500 (`InternalServerError`).

Additionally, the `IntoOutcome` trait was overhauled to support functionality
previously offered by methods on `Outcome`. The `Outcome::forward()` method now
requires a status code to use for the forwarding outcome.

Finally, logging of `Outcome`s now includes the relevant status code.

Resolves #2626.
2023-11-01 18:50:58 -05:00
Sergio Benitez b6430e9970 Rename 'Outcome::Failure' to 'Outcome::Error'.
The primary motivation is to deconflate the leading `F`s in `Failure` and
`Forward`. In particular, when using a generics, we used `F` for forward, which
could easily be confused for `F` for `Failure`. This resolves the conflation.
2023-11-01 18:50:55 -05:00
Sergio Benitez c6192c1c0b Use mixed-site spans to avoid clippy 'uri!' error.
Closes #2630.
2023-10-29 18:27:17 -05:00
Sergio Benitez 923b61edf3 Update UI tests. 2023-10-26 20:25:33 -05:00
许杰友 Jieyou Xu (Joe) 5bdafc272d Use Span::mixed_site to avoid let unit warnings.
Closes #2568.
2023-10-26 20:01:45 -05:00
Ruben Schmidmeister dc9e1ac6a1 Set 'color-scheme' in default catcher HTML. 2023-10-26 20:01:06 -05:00
Sergio Benitez f38103da60 Update dependencies.
* notify: 5 -> 6
  * indexmap: 1 -> 2
  * cookie: 0.18.0-rc.0 -> 0.18
2023-10-26 20:01:06 -05:00
Sergio Benitez a20f9d8e89 Document that '&[u8]' is a form guard. 2023-10-26 20:01:06 -05:00
Sergio Benitez ed56056d0e Update 'cookie' to 0.18. 2023-10-26 20:01:06 -05:00
Sergio Benitez 09cbf2f371 Fix broken links between codegen and http crates.
Also resolves link warnings emitted by rustdoc.

Closes #2594
2023-10-26 20:01:06 -05:00
Sergio Benitez b5d14ff89a Update UI tests for latest rustc. 2023-10-26 19:56:08 -05:00
Sergio Benitez 79399bb1c0 Avoid using 'macro' items on stable.
This gets rid of the warning message on stable when building examples.
2023-10-26 19:56:08 -05:00
Sergio Benitez e7ef93be49 Remove use of 'private_in_public' lint.
The lint no longer exists. This gets rid of a compile-time warning for users.

Resolves #2608.
2023-10-26 19:56:08 -05:00
Sergio Benitez 20a8e2c914 Update UI tests for latest `rustc`. 2023-10-26 19:55:55 -05:00
Manuel Transfeld e581e3f98e Update 'sqlx' to '0.7'. 2023-10-26 19:55:46 -05:00
Sergio Benitez f5c7be24d6 Clarify when 'UriDisplay' can be derived.
Resolves #2595.
2023-10-26 19:54:40 -05:00
Sergio Benitez 546f3f1bd0 Fix 'get_pending()' docs, functionality.
The `get_pending()` method now properly decrypts private cookies that were
present in the jar originally.

Resolves #2591.
2023-10-26 19:54:28 -05:00
Sergio Benitez ed25534426 Update 'yansi' to 1.0.0-rc. 2023-10-26 19:53:24 -05:00
Sergio Benitez 74be8a90a1 Add support for 'diesel-async' to 'db_pools'. 2023-10-26 19:46:35 -05:00
Sergio Benitez 35c62ff74a Remove use of 'unsafe' in 'RawStr' doctests. 2023-10-26 19:46:07 -05:00
Sergio Benitez 40410e4365 Add 'mtls::Certificate::as_bytes()' method. 2023-10-26 19:45:44 -05:00
Sergio Benitez b89a0039a7 Update 'state' to 0.6. 2023-10-26 19:41:28 -05:00
Sergio Benitez 4b7d48967b Warn if a task is spawned in a sync '#[launch]'.
The warning is fairly conservative. Heuristics are used to determine if a call
to `tokio::spawn()` occurs in the `#[launch]` function.

Addresses #2547.
2023-10-26 19:23:12 -05:00
Sergio Benitez e2fb31b63e Document built-in data guards. 2023-10-26 19:22:48 -05:00
Sergio Benitez 6cb60db5f6 Only extract needed values in 'async_main'.
Previously, `async_main` would extract a full `Config`. This mean that values
like `address` were read and parsed even when they were unused. Should they
exist and be malformed, a configuration error would needlessly arise.

This commit fixes this by only extract values that are subsequently used.
2023-10-26 19:22:42 -05:00
Sergio Benitez 83638fcee2 Remove closure borrow in 'FromForm' derive.
The codegen for field validations previously included a closure that
could potentially partially borrow a 'Copy' field of the context
structure. To prevent this, 'let'-assign the field before the closure is
created, and use the assignment inside of the closure.
2023-10-26 19:22:36 -05:00
Sergio Benitez be496682c2 Add 'Error::pretty_print()'. 2023-05-05 18:21:17 -07:00