Commit Graph

415 Commits

Author SHA1 Message Date
Sergio Benitez 543560a1f2 Update 'deadpool' dependencies in 'db_pools'. 2022-02-16 11:07:00 -08:00
Sergio Benitez 0ba5aac53e Update codebase for latest nightly and stable. 2022-02-16 10:08:55 -08:00
Sergio Benitez 8cae077ba1 Add 'Connection::into_inner()' in 'db_pools'.
Resolves #1790.
2021-08-30 04:02:13 -07:00
Sergio Benitez 9bc6c25d2d Fix docs for handlebars update. 2021-08-30 03:44:08 -07:00
Ning Sun 831ffc6c09 Update 'handlebars' to 4.0. 2021-08-30 03:42:57 -07:00
Sergio Benitez 15e74fe184 Update UI tests for latest nightly. 2021-08-19 20:07:10 -07:00
Sergio Benitez a16c66eae9 Propagate 'log_level' to SQLx logs.
Closes #1798.
2021-08-19 19:49:20 -07:00
Jeb Rosen 5cb243fc24 Update UI tests for latest stable. 2021-08-01 12:24:49 -07:00
Sergio Benitez 179be25866 Add 'rocket_db_pools' UI tests. 2021-07-18 13:14:13 -07:00
Sergio Benitez 5b1a04deab Introduce async database pools: 'rocket_db_pools'.
This is the async analog of 'rocket_sync_db_pools', rewritten to be
cleaner, leaner, easier to maintain and extend, and better documented.

Resolves #1117.
Resolves #1187.
2021-07-18 12:17:17 -07:00
Jeb Rosen f7f068be11 Initial implementation of async DB pooling. 2021-07-18 12:14:25 -07:00
Sergio Benitez bb920e6e09 Fix 'context!()' typo: "supports" -> "supported". 2021-07-02 11:44:53 -07:00
Mikail Bagishov be933ce398 Apply clippy suggestions. 2021-06-30 14:13:19 -07:00
Sergio Benitez f0b133023b Fix git repository link to 'rocket_sync_db_pools'. 2021-06-30 10:15:46 -07:00
Dominik Boehi d671ec5bb5 Fix link to 'rocket_dyn_templates' git repository. 2021-06-30 10:14:58 -07:00
Flying-Toast 8e3ad40beb Add 'context!' for ad-hoc templating contexts. 2021-06-30 10:09:28 -07:00
Sergio Benitez ac3efbc892 Use configured database pool timeout on pool init. 2021-06-26 11:58:32 -07:00
Sergio Benitez 0b2fcb9f4b Use Figment's 'Value' in contrib templating.
Previously, 'serde_json::Value' was used to store the serialized
template context. This value does not represent all of serde's data
model. This means we may fail to serialize a valid Rust value into it,
for instance, 128-bit integers. This is reduced with Figment's 'Value',
which supports the majority if not all of the serde data model.

At present, all supported templating engines use 'serde_json::Value', so
in practice, this commit has no effect but to reduce local dependencies
and provide better error messages for bad contexts.
2021-06-25 09:08:49 -07:00
Petr Portnov d9858cf3c7 Add missing documentation for the `run()` method generated by `#[database]`.
Resolves #1704.
2021-06-17 17:31:53 -07:00
Sergio Benitez c028d63e5b New version: 0.5.0-rc.1.
New contrib versions: 0.1.0-rc.1.
2021-06-09 09:52:37 -07:00
Sergio Benitez 6961a717d8 Use crates.io compatible internal package names. 2021-06-09 09:47:21 -07:00
Sergio Benitez 394982edbd Make new contrib libraries publishable. 2021-06-09 04:51:46 -07:00
Sergio Benitez dd9629697a Use published 'devise'. 2021-06-09 00:46:28 -07:00
Sergio Benitez f4ecc3e3bd Update 'sqlite' contrib dependencies. 2021-06-09 00:36:25 -07:00
Sergio Benitez 4c6562cd29 Drop 'Data' after sending a response, not before.
This allows responses to be sent to the client even when data is only
partially read, significantly improving the experience for the client
from one with a "connection closed" error to one with a proper response.
The consequence is a lifetime in 'Data'.

Though other non-lifetime-introducing solutions exist, the introduction
of a lifetime to 'Data' is a longstanding desire as it prevents
smuggling 'Data' into a longer-lived context. Use of 'Data' in that
context was unspecified with various runtime consequences. The addition
of a lifetime bound by the request prevents this error statically.

In summary, the changes are:
  * Clients receive responses even when data isn't fully read.
  * 'Data' becomes 'Data<'r>'. 'FromData' changes accordingly.
  * Route 'Outcome's are strictly tied to the request lifetime.

Tangentially, the invalid length form field validation error message has
improved to format length in byte units if it exceeds 1024.
2021-06-08 13:26:16 -07:00
Sergio Benitez 5f50d5e232 Check for trailing new lines in testing script. 2021-06-07 19:31:23 -07:00
Sergio Benitez 0aa9a11ca4 Fix typos throughout codebase. 2021-06-07 19:31:21 -07:00
Sergio Benitez 735bd99549 Update 'normpath' to 0.3. 2021-05-29 15:33:15 -07:00
Sergio Benitez 6b4c1b71d7 Update 'tokio' to 1.6.1. 2021-05-29 15:33:15 -07:00
Sergio Benitez 1f1976f8bf Avoid Tokio 1.6 due to tokio-rs/tokio#3803. 2021-05-27 15:25:57 -07:00
Sergio Benitez 41d7138540 Allow custom generic bounds in 'Responder' derive. 2021-05-26 02:26:11 -07:00
Sergio Benitez 02d6c4c6f1 Remove 'default-features' from contrib examples. 2021-05-25 05:28:58 -07:00
Sergio Benitez 5a4e66ec43 Split 'rocket_contrib' into distinct crates.
This follows the completed graduation of stable contrib features into
core, removing 'rocket_contrib' in its entirety in favor of two new
crates. These crates are versioned independently of Rocket's core
libraries, allowing upgrades to dependencies without consideration for
versions in core libraries.

'rocket_dyn_templates' replaces the contrib 'templates' features. While
largely a 1-to-1 copy, it makes the following changes:

  * the 'tera_templates' feature is now 'tera'
  * the 'handlebars_templates' feature is now 'handlebars'
  * fails to compile if neither 'tera' nor 'handlebars' is enabled

'rocket_sync_db_pools' replaces the contrib 'database' features. It
makes no changes to the replaced features except that the `database`
attribute is properly documented at the crate root.
2021-05-24 22:57:51 -07:00
rotoclone bacbf073ce Clarify that 'Template' is a proxy type. 2021-05-22 22:05:04 -07:00
Sergio Benitez b1d05d20ac Graduate 'serve' into core as 'fs', 'FileServer'.
This completes the graduation of stable 'contrib' features to 'core'.

Closes #1107.
2021-05-22 11:15:56 -07:00
Sergio Benitez a78814f1c5 Graduate contrib 'uuid' into core.
This has the following nice benefits:

  * The 'Uuid' wrapper type is gone.
  * 'Uuid' implements 'UriDisplay', 'FromUriParam'.
  * The 'serialization' example merges in 'uuid'.

Resolves #1299.
2021-05-22 11:01:00 -07:00
Sergio Benitez f6a7087c84 Graduate 'helmet' as 'shield' into core.
The 'SpaceHelmet' fairing is now called 'Shield'. It features the
following changes and improvements:

  * Headers which are now ignored by browsers are removed.
  * 'XssFilter' is no longer an on-by-default policy.
  * A new 'Permission' policy is introduced.
  * 'Shield' is attached to all 'Rocket' instances by default.
  * Default headers never allocate on 'Clone'.
  * Policy headers are rendered once and cached at start-up.
  * Improved use of typed URIs in policy types.
2021-05-22 11:01:00 -07:00
Sergio Benitez c74bcfd40a Graduate contrib 'json' and 'msgpack' into core.
This has the following nice benefits:

  * The 'JsonValue' wrapper type is gone.
  * 'Local{Request, Response}' natively support JSON/MessagePack.
  * The 'json' and 'msgpack' limits are officially recognized.
  * Soon, Rocket application will not require an explicit 'serde' dep.

This marks the beginning of the end of 'rocket_contrib'.
2021-05-22 11:01:00 -07:00
Sergio Benitez f85604b65e Use upstream 'Tera.get_template_names()'.
Resolves #1637.
2021-05-21 11:39:20 -07:00
Sergio Benitez fa3e0334c1 Overhaul URI types, parsers, 'uri!' macro.
This commit entirely rewrites Rocket's URI parsing routines and
overhauls the 'uri!' macro resolving all known issues and removing any
potential limitations for compile-time URI creation. This commit:

  * Introduces a new 'Reference' URI variant for URI-references.
  * Modifies 'Redirect' to accept 'TryFrom<Reference>'.
  * Introduces a new 'Asterisk' URI variant for parity.
  * Allows creation of any URI type from a string literal via 'uri!'.
  * Enables dynamic/static prefixing/suffixing of route URIs in 'uri!'.
  * Unifies 'Segments' and 'QuerySegments' into one generic 'Segments'.
  * Consolidates URI formatting types/traits into a 'uri::fmt' module.
  * Makes APIs more symmetric across URI types.

It also includes the following less-relevant changes:

  * Implements 'FromParam' for a single-segment 'PathBuf'.
  * Adds 'FileName::is_safe()'.
  * No longer reparses upstream request URIs.

Resolves #842.
Resolves #853.
Resolves #998.
2021-05-19 18:47:11 -07:00
Sergio Benitez f6568aca68 Update UI tests for latest nightly. 2021-05-18 12:00:46 -07:00
Sergio Benitez 1c600bda30 Discover manually registered templates.
This includes one breaking change: the default Content-Type of templates
without an identifying extension is now 'Text'. This is to prevent Tera
templates from rendering as HTML without being escaped.

Resolves #1637.
2021-05-18 11:40:10 -07:00
Sergio Benitez d03a07b183 Retrieve managed state via a borrow: '&State<T>'.
This has the following positive effects:

  1) The lifetime retrieved through 'Deref' is now long-lived.
  2) An '&State<T>` can be created via an '&T'.
  3) '&State<T>' is shorter to type than 'State<'_, T>'.
2021-05-11 08:58:16 -05:00
Sergio Benitez d21608ca7b Remove 'Content' in favor of 'content::Custom'.
Also adds the shorthand '(ContentType, R)', where 'R: Responder',
responder implementation. This brings it to parity with the
'response::status' API.
2021-04-28 01:21:57 -07:00
Sergio Benitez 9ad4fb2781 Use 'default', not 'global' profile in db docs. 2021-04-28 01:13:11 -07:00
Sergio Benitez 068aacd79d Require source lines to be under 100 chars. 2021-04-27 20:19:35 -07:00
Jeb Rosen 078cf1725f Init sync DB pools inside of 'spawn_blocking'.
One situation where this is noticeable is when initialization failure
leads to `Drop`; unlike in a successful initialization, `postgres`
detects and panics when `Drop` is called from within asynchronous code.
Several other database pools do not panic in this same situation, but
would still block the current thread.

Also sets the minimum version of `tokio` to 1.4 in `rocket_contrib`,
which is the version where `Handle::block_on` (used in `Drop` impls) was
introduced.

Fixes #1610.
2021-04-27 19:32:38 -07:00
Sergio Benitez 801e04bd53 Log guard failures, potential misuses.
This commit includes changes that improve how and what Rocket logs
automatically. Rocket now logs:

  * All guard errors, indicating the failing guard kind and type.
  * A warning when a 'TempFile' is used as a data guard for a request
    that specifies a 'form' Content-Type.
  * Only the top/sub of a request's format.

This commit makes the following breaking changes:

  * '<T as FromData>::Error' must implement 'Debug'.

Furthermore, this commit restores the previous behavior of always
logging launch info. It further restores the unspecified behavior of
modifying logging state only when the set logger is Rocket's logger.
2021-04-23 19:19:39 -07:00
Jeb Rosen e1307ddf48 Ensure synchronous database connections are not dropped from inside async tasks.
Fixes #1610.
2021-04-21 14:51:55 -07:00
Sergio Benitez dd0c036461 Allow 'T: Deserialize' in JSON, MessagePack forms.
Previously, 'T: DeserializeOwned' was required needlessly. This allowed
'Json' and 'MsgPack' to borrow from the request.
2021-04-16 01:51:31 -07:00