Commit Graph

1976 Commits

Author SHA1 Message Date
Sergio Benitez 579508d58f Make 'FileName' a DST. Improve sanitization.
Resolves #1594.
2021-04-03 17:09:00 -07:00
Jonah Brüchert fa1b75ba74 Allow accessing raw file name from 'DataField'. 2021-04-03 17:07:20 -07:00
Sergio Benitez 0654890e3d Add copy methods to 'TempFile'.
Resolves #1600.
2021-04-01 13:27:37 -07:00
Sergio Benitez 2893ce754d Introduce scoped catchers.
Catchers can now be scoped to paths, with preference given to the
longest-prefix, then the status code. This a breaking change for all
applications that register catchers:

  * `Rocket::register()` takes a base path to scope catchers under.
    - The previous behavior is recovered with `::register("/", ...)`.
  * Catchers now fallibly, instead of silently, collide.
  * `ErrorKind::Collision` is now `ErrorKind::Collisions`.

Related changes:

  * `Origin` implements `TryFrom<String>`, `TryFrom<&str>`.
  * All URI variants implement `TryFrom<Uri>`.
  * Added `Segments::prefix_of()`.
  * `Rocket::mount()` takes a  `TryInto<Origin<'_>>` instead of `&str`
    for the base mount point.
  * Extended `errors` example with scoped catchers.
  * Added scoped sections to catchers guide.

Internal changes:

  * Moved router code to `router/router.rs`.
2021-03-28 13:57:33 -07:00
Sergio Benitez c3bad3a287 Fix small typo in lib.rs. 2021-03-27 18:25:46 -07:00
Sergio Benitez feadb4dd16 Prefer '&str' in doc examples. 2021-03-27 16:25:39 -07:00
Sergio Benitez 3045e0ac63 Add doc notes on how to depend on '-dev' versions. 2021-03-27 14:20:43 -07:00
Sergio Benitez 78d749b265 Use explicit 'serde-1' 'indexmap' feature. 2021-03-27 14:10:38 -07:00
Sergio Benitez f7b32e0817 Update to latest 'multer'. 2021-03-27 03:37:37 -07:00
Sergio Benitez ff22645d3a Remove upstream unmaintained 'mysql' support.
Also updates 'sqlite' dependencies.
2021-03-27 02:42:04 -07:00
Sergio Benitez 4c0d66b6b1 Update 'pin-project-lite' to 0.2. 2021-03-27 01:03:46 -07:00
Sergio Benitez 0be3b41687 Add '--benchmarks' target to testing script. 2021-03-26 20:12:19 -07:00
Sergio Benitez 3119e6f453 Redesign routing benchmarks.
The new benchmarks use routes from real-world project. This is much more
realistic than the previous benchmarks.

The new benchmarks use `criterion` and exist in their own Cargo project.
2021-03-26 20:02:49 -07:00
Sergio Benitez 20605dac14 Set default route rank using "colorings".
This new system colors paths and queries in one of three ways:

  1. `static`, meaning all components are static
  2. `partial`, meaning at least one component is dynamic
  3. `wild`, meaning all components are dynamic

Static paths carry more weight than static queries. The same is true for
partial and wild paths. This results in the following default rankings:

| path    | query   | rank |
|---------|---------|------|
| static  | static  | -12  |
| static  | partial | -11  |
| static  | wild    | -10  |
| static  | none    | -9   |
| partial | static  | -8   |
| partial | partial | -7   |
| partial | wild    | -6   |
| partial | none    | -5   |
| wild    | static  | -4   |
| wild    | partial | -3   |
| wild    | wild    | -2   |
| wild    | none    | -1   |
2021-03-26 19:41:00 -07:00
Sergio Benitez ec1ccc248c Test 'Limits::{find,get}' with tri-level limits. 2021-03-25 18:52:04 -07:00
Sergio Benitez 630a458417 Expose active 'Rocket' via 'Request::rocket()'. 2021-03-25 18:33:15 -07:00
Sergio Benitez 9cb2552055 Inline a few more 'Request' methods. 2021-03-25 18:19:34 -07:00
Sergio Benitez af598fb872 Use concrete lifetime in 'Request::uri()'. 2021-03-25 18:17:51 -07:00
Sergio Benitez 4741ae0787 Fix minor typo in requests guide. 2021-03-25 18:06:12 -07:00
Sergio Benitez e7934a2a3f Parse inner form 'T' in 'Option<T>' strictly.
This behavior more closely matches the expectation that a missing field
results in 'None'.

Also cleans up forms docs for readability, completeness.
2021-03-24 19:53:13 -07:00
Sergio Benitez 33790254f1 Store full '&Rocket' in '&Request'.
This is instead of storing pieces of the active Rocket instance.
2021-03-24 11:59:23 -07:00
Sergio Benitez 81346e5949 Don't expose hidden 'Route' collider methods. 2021-03-20 03:04:31 -07:00
Sergio Benitez b3021e2acb Fix all broken links. Update some outdated docs. 2021-03-19 18:09:13 -07:00
Sergio Benitez def9b4dcd2 Always emit 'Request<'_>', with lifetime. 2021-03-19 18:05:27 -07:00
Sergio Benitez 84fda62678 Emit query parse code only when there's a query. 2021-03-19 18:04:28 -07:00
Sergio Benitez 8749d7293a Simplify and optimize router.
This surfaced a dormant concurrency related issue. Prior to this commit,
the router used `routed_segments()` to retrieve the path segments of the
request. This was okay as there was no route in the request, and matched
segments were retrieved eagerly.

This commit makes segment matching lazy, so no matching occurs if
unnecessary. Between two matches, a `route` is atomically set of
`Request`. This is now visible in `routed_segments()`, which should not
have considered the current route in the first place. This was fixed.
2021-03-19 03:49:58 -07:00
Sergio Benitez 39d7931d6a Expose 'router' module, document 'RouteUri'. 2021-03-19 03:49:58 -07:00
Ben Sully 97acd8d9a9 Update tests and docstrings for 'RouteUri'. 2021-03-19 03:49:58 -07:00
Sergio Benitez 2463637d51 Introduce 'RouteUri'.
Co-authored-by: Ben Sully <ben@bsull.io>
2021-03-19 03:49:54 -07:00
Sergio Benitez 487485d108 Explicitly specify 'template_dir' in forms example. 2021-03-17 18:34:05 -07:00
Sergio Benitez b24e53454a Generate CA cert in 'gen_certs.sh'. 2021-03-17 18:25:06 -07:00
Abdullah Alyan af48d1f2e6 Support more TLS key types in PKCS format.
Closes #1449.
Resolves #1461.
2021-03-17 18:23:15 -07:00
Sergio Benitez f254504dc9 Depend on a single revision of 'state'.
Closes #1577.
2021-03-15 02:46:34 -07:00
Sergio Benitez 1b2edd38b3 Clarify 'TempFile' configuration parameters. 2021-03-15 02:43:01 -07:00
Sergio Benitez f9d4a78fbb Fix spacing in 'Route::default_rank()'. 2021-03-15 02:39:21 -07:00
Sergio Benitez 9c678e606b Track and log catcher names. 2021-03-15 02:27:53 -07:00
Sergio Benitez 304e65ac72 Catch panics that occur before future is returned.
In the course of resolving this issue, double-boxing of handlers was
discovered and removed.
2021-03-15 02:20:48 -07:00
Sergio Benitez 70b42e6f0e Remove second lifetime from 'FromRequest'.
While offering some utility, the lifetime did not carry its weight, and
in practice offered no further ability to borrow. This greatly
simplifies request guard implementations.
2021-03-14 19:57:59 -07:00
Sergio Benitez 2366bff05f Rearrange contrib database support modules. 2021-03-12 15:44:19 -08:00
Sergio Benitez 4b09e77ccb Decrease lock period while reloading templates.
Previously, an `rx` lock was held for the entirety of the check period,
effectively making request handling serial. The implementation also held
a `write` lock to templating context while an expensive user-callback
was called, limiting template-related concurrency during that period.
This was changed so no lock is held during that period and a write-lock
is held only for the duration of the context field write.
2021-03-11 02:55:38 -08:00
Sergio Benitez e532f4e2b3 Disallow defaults in strict forms.
Partially resolves #1536.
2021-03-11 02:03:13 -08:00
Sergio Benitez ef7b7a953e Improve forms guide. 2021-03-11 01:12:20 -08:00
Sergio Benitez 8283bf0a2b Make obvious when and which tests in '--all' fail. 2021-03-10 22:52:37 -08:00
Sergio Benitez f483edaafb Remove unused imports in fairings test. 2021-03-10 22:30:23 -08:00
Sergio Benitez c0caa3b874 Fix codegen doctests for 'Route.name' changes. 2021-03-10 22:28:06 -08:00
Sergio Benitez a0e4c9677c Allow dynamic route names. Log 'StaticFiles' root. 2021-03-10 18:40:38 -08:00
Sergio Benitez 191b93498e Remove boxed futures in server, use async fn. 2021-03-10 16:31:32 -08:00
Sergio Benitez 88cb6ec4d1 Always test on stable on publish. 2021-03-10 14:56:34 -08:00
Sergio Benitez 015438a780 Print config on attach in config example. 2021-03-10 03:37:03 -08:00
Sergio Benitez 3c25326917 Log only non-empty fairing classes. 2021-03-10 02:30:13 -08:00