Commit Graph

2408 Commits

Author SHA1 Message Date
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
Sergio Benitez d4723bb3ee Pin macOS CI 'mysql-client' to '8.4'.
mysqlclient-sys does not recognize v9, which causes the CI to fail. This
resolves the issue.
2024-08-09 01:02:39 -07:00
loikki 38cebebbc3
Derive FromParam for Enum #2826 2024-08-07 22:52:30 -05:00
Flozza 509a033c84
Fix wrong URL in guide (configuration) 2024-08-07 21:36:52 -05:00
Sergio Benitez f2ca2ad735 Add 'RocketDynFmt' subscriber constructor.
Resolves #2840.
2024-08-05 22:24:47 -07:00
Abraham Egnor 4eb6cdf8fb Update 'mongodb' to 3.0. 2024-07-22 15:36:19 -05:00
Alessandro Campeis e2cbcc6e2f Update 'handlebars' to 6.0. 2024-07-22 14:09:21 -05:00
Sergio Benitez f50b6043e8 Improve FileServer rewrite API.
Finalizes the FileServer rewrite API implementation. Primarily reworks
how the built-in rewriters are written (now as structs instead of free
functions) and reorganizes the `fs` module.

Co-authored-by: Matthew Pomes <matthew.pomes@pm.me>
2024-07-06 15:34:21 +02:00
Matthew Pomes 65e3b87d6b Implement FileServer rewrite API.
Implements the FileServer API proposed in
https://github.com/rwf2/Rocket/pull/2716#issuecomment-1930893889.

Closes #2716.
2024-07-06 15:33:43 +02:00
Vadim Anufriev fb4b630405
Add MiniJinja for templating example (#2799)
Update guide to mention MiniJinja.
Adds MiniJinja to the templating example.
2024-06-26 01:27:44 -05:00
Matthew Pomes 6857b82ec4 Use codegen event target prefix 'rocket::codegen'.
This commit prefixes the target of all trace events emitted by codegen
with `rocket::codegen::{kind}::{module_path!()}`, where `kind` is the
kind of codegen item that was generated (i.e, `route`). This increases
the consistency of trace messages emitted by Rocket so that they all
begin with 'rocket::'.
2024-06-10 19:56:37 -05:00
Sergio Benitez 606cd61e3f Install NASM on Windows CI job. 2024-06-10 14:47:25 -07:00
Sergio Benitez 4a00c1fe77 Improve 'Error' type: make 'ErrorKind' accessible.
This commit improves the 'Error' type such that:
  - It is now fully documented.
  - The `ErrorKind` enum variant fields are all publicly reachable.
  - The `Sentry` type is exposed.

This is a breaking change:
  - `ErrorKind::Collisions` is now struct-like with two fields.
2024-06-03 20:11:20 -07:00
Sergio Benitez 926e06ef3c Finalize 'tracing' migration.
This commit complete the migration to 'tracing' for all logging. Below
is a summary of all relevant commits, including this one:

Log improvements:
  - All log (trace) messages are structured which means they contain fields
    that can formatted by any subscriber.
  - Logging can be disabled entirely by disabling the default `trace` feature.
  - Routes and catchers now contain location (file/line) information.
  - Two log format kinds: pretty and compact via ROCKET_LOG_FORMAT
  - Coloring is not disabled globally. Thus applications can color even if
    Rocket is configured not to.
  - Rocket is more conservative about 'warn' and 'error' messages, reserving
    those log levels for messages useful in production.
  - Errors from guards logged by codegen now use the 'Display' implementation of
    those errors when one exists.
  - Secrets are never logged, even when directly asked for.

New features:
  - Many Rocket types know how to trace themselves via a new `Trace` trait.
  - `Either` types can now be used in `uri!()` calls.
  - A `RequestIdLayer` tags all requests with a unique ID.

Breaking changes to configuration:
  - `Config::log_level` is of type `Option<Level>`. `None` disables tracing.
  - `log_level` now uses the traditional log level names: "off", "error",
    "warn", "info", "debug", "trace", or 0-5. This replace the Rocket-specific
    "normal", "debug", "critical".
  - A new option, `log_format`, which is either `compact` or `pretty`,
    determines how Rocket's tracing subscriber log trace messages.

Breaking changes:
  - Hidden `rocket::Either` is now publicly available at `rocket::either::Either`.
  - `rocket::Error` no longer panics when dropped.
  - `main` generated by `#[launch]` returns an `ExitCode`.
  - `FromParam` `Err` now always returns the actual error as opposed to the
    string that failed to parse. To recover the original string, use `Either<T,
    &str>`, where `T: FromParam`, as a parameter guard.
  - Many types that implemented `Display` now instead implement `Trace`.
  - `Error::pretty_print()` was removed. Use `Error::trace()` via `Trace` impl.

Internal improvements:
  - Made more space in CI machines for tasks.
  - Cleaned up testbench code using `inventory`.

Resolves #21.
2024-06-03 15:02:44 -07:00
Sergio Benitez 45264de8c9 Allow dynamic selection of log format. 2024-06-03 14:39:20 -07:00
Sergio Benitez cc2b159e85 Document the new 'trace' feature. 2024-06-03 14:39:12 -07:00
Sergio Benitez b12b7f27d7 Remove old 'log' macros. Color via subscriber.
This commit:
  - Removes painting outside trace subscriber in core.
  - Removes all non-subscriber uses of yansi.
  - Removes all uses of old log macros.
  - Fix trace exports.
2024-06-03 14:39:12 -07:00
Sergio Benitez d767694861 Remove 'Error' panic-on-drop behavior.
Instead, the `#[launch]` attribute traces the error and panics,
replicating the old behavior in the common case.
2024-06-03 14:38:34 -07:00
Sergio Benitez 8a1c91b7d5 Implement 'Trace' trait. Use structured logging.
This commit:
  - Converts most log messages into structured messages.
  - Implements an initial request ID layer.
  - Implements pretty and compact loggers.
2024-06-03 14:33:24 -07:00
Sergio Benitez ff6da900a0 Migrate to 'tracing' for logging.
This commit:
  - Remove all traces of 'log'.
  - Send all logs unedited via tracing.
  - Parses and propagate log_level.
  - Implements an initial formatting subscriber.

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
Co-authored-by: Jeb Rosen <jeb@jebrosen.com>
2024-06-03 14:32:01 -07:00
Sergio Benitez 5cecc9f0be Detect and handle MessageStream WebSocket closure. 2024-05-31 13:36:32 -05:00
Sergio Benitez abd7335f77 Free more disk space on Linux CI. 2024-05-31 13:36:32 -05:00
Cormac Relf 120d1e78da Generate deterministic names for 'uri' macros. 2024-05-29 15:21:49 -05:00
Sergio Benitez 2a1afd12f5 Add 0.5.1 CHANGELOG entry. 2024-05-23 15:48:35 -05:00
Sergio Benitez 091c6f58f6 Update 'deadpool' and related databases to 0.13. 2024-05-22 19:48:17 -05:00
Arjen cde1fb5de0 Improve example TOML in configuration guide. 2024-05-22 16:52:32 -05:00
Sergio Benitez 9e3f9ae00f Update 'minijinja' to 2.0. 2024-05-22 15:03:18 -05:00
Michael Melanson 347d9da663 Improve minijinja and tera template error logs. 2024-05-22 14:46:03 -05:00
Bill 35a100fdec Remove double semicolon in SSE example 2024-05-22 14:38:20 -05:00
Sergio Benitez 3079dbfa85 Use workspace lints. Resolve new nightly warnings. 2024-05-20 13:39:14 -05:00
Sergio Benitez bb48a4d724 Fix 'since' version in 'deprecated' attribute. 2024-05-07 02:18:27 -07:00
Sergio Benitez 370287c9a6 Fix 'TcpListener' port required regression. 2024-05-03 17:17:56 -07:00
Sergio Benitez 5f9ff3f3af 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-02 16:18:53 -07:00
Sergio Benitez fd2094c5f3 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-02 16:18:51 -07:00
Sergio Benitez 7b17de6699 Improve 'sync_db_pools' codegen. Update UI tests. 2024-05-02 16:16:00 -07:00
Sergio Benitez a811a1810d Support sqlx_sqlite extensions in db_pools.
Resolves #2762.
2024-05-02 01:46:13 -07:00
Sergio Benitez fb39c02212 Fix macOS CI native deps install step. 2024-05-02 01:46:13 -07:00
Sergio Benitez e6aaea072c Use 'dep' syntax for 'http' features. 2024-04-26 01:42:33 -07:00
Sergio Benitez 84072a813a Add deploying guide.
Resolves #171.
2024-04-25 20:03:44 -07:00
Sergio Benitez 836e64fec3 Rename 'Rocket::configure()' to 'reconfigure()'. 2024-04-25 14:47:43 -07:00
Sergio Benitez b34085392d Add 'Method' variants for all registered methods.
This commit allow routes to be declared for methods outside of the
standard HTTP method set. Specifically, it enables declaring routes for
any method in the IANA Method Registry:

```rust
#[route(LINK, uri = "/<foo>")]
fn link() { ... }

#[route("VERSION-CONTROL", uri = "/<foo>")]
fn version_control() { ... }
```

The `Method` type has gained variants for each registered method.

Breaking changes:

  - `Method::from_str()` no longer parses mixed-case method names.
  - `Method` is marked as non-exhaustive.
  - `Method::supports_payload()` removed in favor of
    `Method::allows_request_body()`.

Resolves #232.
2024-04-24 19:22:03 -07:00
Sergio Benitez 7c50a58c99 Fix TLS example for updated bind interface. 2024-04-22 17:57:34 -07:00
Sergio Benitez 85ca2bc01c Refactor internal ignite sequencing. 2024-04-22 17:27:01 -07:00
Sergio Benitez 3bfc4ca644 Simplify 'Bind'. Allow try-launching on Futures. 2024-04-22 17:26:51 -07:00
Sergio Benitez 7cc818cd85 Introduce dynamic TLS resolvers.
This commit introduces the ability to dynamically select a TLS
configuration based on the client's TLS hello via the new `Resolver`
trait. In support of this, it also makes the following changes:

  * Added `Authority::set_port()`.
  * `UdsListener` is now `UnixListener`.
  * `Bindable` removed in favor of new `Bind`.
  * All built-in listeners now implement `Bind<&Rocket>`.
  * `Connection` requires `AsyncRead + AsyncWrite`.
  * The `Debug` impl for `Endpoint` displays the underlying address.
  * `Listener` must be `Sized`.
  * The TLS listener was moved to `tls::TlsListener`.
  * The preview `quic` listener no longer implements `Listener`.
  * Added `TlsConfig::server_config()`.
  * Added `race` future helpers.
  * Added `Rocket::launch_with()`, `Rocket::bind_launch()`.
  * Added a default `client.pem` to the TLS example.
  * Various unnecessary listener `Config` structures removed.

In addition, the testbench was revamped to support more scenarios. This
resulted in the following issues being found and fixed:

  * Fix an issue where the logger would ignore color requests.
  * Clarified docs for `mtls::Certificate` guard.
  * Improved error messages on listener misconfiguration.

Resolves #2730.
Resolves #2363.
Closes #2748.
Closes #2683.
Closes #2577.
2024-04-16 23:50:28 -07:00
Sergio Benitez 60f3cd57b0 Add end-to-end testbench.
Resolves #1509.
2024-04-12 03:15:44 -07:00
Sergio Benitez eec5c08179 Make all nightly CI jobs fallible. 2024-04-11 19:17:06 -07:00
Sergio Benitez 8831d47aad Restrict CI trigger job to 'rwf2/Rocket'. 2024-04-11 18:22:28 -07:00
Rong "Mantle" Bao ff12b1d4bc Update allowed lints for MSRV of 1.75. 2024-04-11 18:13:37 -07:00