Commit Graph

1812 Commits

Author SHA1 Message Date
Brendon Federko e68a951a54 Upodate tests for latest stable. 2021-01-12 14:52:34 -08:00
Sergio Benitez 9671115796 Use 'workers' value from 'Config::figment()'.
This commit also improves config pretty-printing and warning messages.
It also fixes an issue that resulted in config value deprecation
warnings not being emitted. The 'workers' value is now a 'usize', not a
'u16'; contrib pool sizes now default to 'workers * 2'.

Closes #1470.
2020-12-24 15:58:48 -08:00
Jeb Rosen 1f1f44f336 Update UI tests for latest stable. 2020-11-21 12:42:57 -08:00
Jeb Rosen bcb8b3334b Update CI to use GitHub 'environment files'. 2020-11-18 12:38:24 -08:00
Sergio Benitez fa77435187 Bust cache on 'Request::{add,replace}_header()'.
Also changes 'Header::name()' to return '&UncasedStr'.

Resolves #518.
2020-11-05 21:03:58 -08:00
Jeb Rosen c6298b9e11 Use 'spawn_blocking' to drop sync database pools.
This was already done for the connections, but pools might also do
synchronous/blocking work on Drop.

Fixes #1466.
2020-11-05 00:06:41 -08:00
Jeb Rosen 2f98299272 Allow fallible callback in 'Template::try_custom()'.
Closes #1064.
2020-11-04 02:40:53 -08:00
Sergio Benitez 007c4b093f Use '#[rocket::main]', not '#[main]'. 2020-11-03 14:20:29 -08:00
Sergio Benitez bb295ae21b Update console output in guide. 2020-11-03 12:56:20 -08:00
Sergio Benitez 86a6b4b12f Improve async, mount sections of overview guide.
Resolves #1458.
Closes #1464.
2020-11-03 12:52:31 -08:00
Sergio Benitez 86ff66a69c Streamline raw identifier support in codegen. 2020-11-03 12:07:23 -08:00
Jeb Rosen 97f6bc5dc0 Support raw identifiers in forms, routes, uri.
Resolves #881.
2020-11-03 01:42:37 -08:00
Sergio Benitez b5e4dded8a Accept browser-sent unencoded query characters.
Closes #941.

Co-authored-by: Vladimir Ignatev <ya.na.pochte@gmail.com>
2020-11-02 15:08:33 -08:00
Sergio Benitez 949bb01e2d Generate path encoding set using 'const fn'.
Co-authored-by: Jakub Wieczorek <jakub.adam.wieczorek@gmail.com>
2020-11-01 21:26:31 -08:00
Sergio Benitez 337e8843a4 Use 'Option', 'Result' directly in 'uri!' query.
Prior to this commit, the conversion 'T -> Option<T>' was applied in
both the path and query parts of a URI in the 'uri' macro via the
'FromUriParam' trait with no implementation for 'Option<T>' directly.
This meant that it was impossible to directly render an 'Option<T>'.
This was exactly desired for the path part, where rendering a 'None'
would yield an incorrect URI, but the restriction was too strict for the
query part, where a 'None' is entirely valid. This commit makes changes
the conversion so that it only applied to path parts and adds the
identity conversions for 'Option<T>' and 'Result<T, E>' for query parts.

The side effect is a breaking change: due to conflicting impls, the 'T'
to 'Option<T>' conversion was removed for query parts. Thus, all 'uri!'
query route arguments of type 'Option' or 'Result' must now be wrapped
in 'Some' or 'Ok'. Due to new 'Option<T> <-> Result<T, E>' conversions,
either 'Some' _and_ 'Ok' work in both contexts.

Closes #1420.
2020-11-01 10:30:30 -08:00
Sergio Benitez edc91f65b7 Mimic Rocket's config in custom providers example. 2020-10-30 03:08:26 -07:00
Compro Prasad de1cffba46 Remove unnecessary 'RawStr.as_str()' in guide.
Closes #1454.
2020-10-30 02:49:00 -07:00
Sergio Benitez 55b651bd70 Use 'rocket::custom()' for 'State' tests. 2020-10-30 02:49:00 -07:00
Jonty b7565172eb Impl 'Clone' for 'State'.
Resolves #1411.
2020-10-30 02:16:24 -07:00
Sergio Benitez a6f5a63535 Add tests for ignored parameters '<_>'.
Co-authored-by: timokoesters <timo@koesters.xyz>
2020-10-30 00:47:41 -07:00
Sergio Benitez 8e8fb4cae8 Allow ignored route path segments.
Co-authored-by: timokoesters <timo@koesters.xyz>
2020-10-30 00:06:39 -07:00
Sergio Benitez 23738446f0 Impl 'std::error::Error' for 'Error'.
Resolves #1460.
2020-10-27 16:04:25 -07:00
Sergio Benitez 8570afff3e Use threaded scheduler in tests.
This prevents async I/O timeouts in attach fairings.

Co-authored-by: Jeb Rosen <jeb@jebrosen.com>
2020-10-26 13:29:36 -07:00
Sergio Benitez 0c150c2a0e Remove unused 'config' examples tests. 2020-10-22 18:13:19 -07:00
Sergio Benitez 09f0087034 Split server parts of 'Rocket' into 'server.rs'. 2020-10-22 18:00:07 -07:00
Sergio Benitez 198b6f0e97 Fix various broken rustdoc links. 2020-10-22 03:53:07 -07:00
Sergio Benitez 08510302da Add 'Rocket::catchers()', rearrange other getters. 2020-10-22 03:41:02 -07:00
Sergio Benitez ec9b5816a8 Remove 'rocket::inspect()', 'Cargo'.
This commit reverts most of dea940c7 and d89c7024. The "fix" is to run
attach fairings on a new thread. If a runtime is already running, it is
used. Otherwise, the future is executed in a single-threaded executor.
2020-10-22 03:27:04 -07:00
Sergio Benitez 491b229582 Improve database config errors. 2020-10-21 23:54:54 -07:00
Sergio Benitez aabbfcfe94 Add 'PoolResult' alias; rename 'DbError' to 'Error'. 2020-10-21 22:33:55 -07:00
Daniel Wiesenberg f5fd1007e2 Move config extraction to 'Poolable' impls. 2020-10-21 22:33:15 -07:00
Sergio Benitez 17fd7f4286 Update minimum rustc to 1.46. 2020-10-21 19:56:12 -07:00
Sergio Benitez bbfe2ba5cc Point all docs and doc links to 'master' branch. 2020-10-21 04:54:24 -07:00
Sergio Benitez 4b4e918a70 Manage state, not 'lazy_static', in 'uuid' example. 2020-10-20 21:02:29 -07:00
George Cheng 0673986c32 Impl 'FromRequest' for 'IpAddr'.
Closes #1414.
2020-10-20 20:51:26 -07:00
ThouCheese 080d586a35 Impl 'DerefMut' for 'Form', 'LenientForm'. 2020-10-20 20:45:43 -07:00
est31 b18cd6460e Add AVIF (image/avif) as a known media type. 2020-10-20 20:40:18 -07:00
Sergio Benitez 730a2dcdbe Implement 'Serialize' for 'Flash'.
Resolves #184.
2020-10-20 20:29:55 -07:00
Sergio Benitez 7337321efb Take '&mut Data' in 'on_request' fairings.
Resolves #1438.
2020-10-20 20:22:32 -07:00
Sergio Benitez 1fb061496d Revamp configuration.
This commit completely overhauls Rocket's configuration systems, basing
it on the new Figment library. It includes many breaking changes
pertaining to configuration. They are:

  * "Environments" are replaced by "profiles".
  * 'ROCKET_PROFILE' takes the place of 'ROCKET_ENV'.
  * Profile names are now arbitrary, but 'debug' and 'release' are given
    special treatment as default profiles for the debug and release
    compilation profiles.
  * A 'default' profile now sits along-side the meta 'global' profile.
  * The concept of "extras" is no longer present; users can extract any
    values they want from the configured 'Figment'.
  * The 'Poolable' trait takes an '&Config'.
  * The 'secrets' feature is disabled by default.
  * It is a hard error if 'secrets' is enabled under the 'release'
    profile and no 'secret_key' is configured.
  * 'ConfigBuilder' no longer exists: all fields of 'Config' are public
    with public constructors for each type.
  * 'keep_alive' is disabled with '0', not 'false' or 'off'.
  * Inlined error variants into the 'Error' structure.
  * 'LoggingLevel' is now 'LogLevel'.
  * Limits can now be specified in SI units: "1 MiB".

The summary of other changes are:

  * The default config file can be configured with 'ROCKET_CONFIG'.
  * HTTP/1 and HTTP/2 keep-alive configuration is restored.
  * 'ctrlc' is now a recognized config option.
  * 'serde' is now a core dependency.
  * TLS misconfiguration errors are improved.
  * Several example use '_' as the return type of '#[launch]' fns.
  * 'AdHoc::config()' was added for simple config extraction.
  * Added more documentation for using 'Limits'.
  * Launch information is no longer treated specially.
  * The configuration guide was rewritten.

Resolves #852.
Resolves #209.
Closes #1404.
Closes #652.
2020-10-20 19:21:56 -07:00
Sergio Benitez 8da034ab83 Update 'devise'. 2020-10-15 01:01:30 -07:00
Sergio Benitez 5615767ca6 Add proper 'cfg' to 'get_private_pending()'. 2020-10-15 00:46:30 -07:00
Sergio Benitez 5cf249581f Add 'const' constructor for 'MediaType'. 2020-10-14 23:54:37 -07:00
Sergio Benitez 079e458b62 Add (un)tracked 'Client' integration tests. 2020-10-14 21:47:42 -07:00
Sergio Benitez 5d9035ddc1 Keep an op-log for sync 'CookieJar'.
In brief, this commit:

  * Updates to the latest upstream 'cookie', fixing a memory leak.
  * Make changes to 'CookieJar' observable only through 'pending()'.
  * Deprecates 'Client::new()' in favor of 'Client::tracked()'.
  * Makes 'dispatch()' on tracked 'Client's synchronize on cookies.
  * Makes 'Client::untracked()' actually untracked.

This commit updates to the latest 'cookie' which removes support for
'Sync' cookie jars. Instead of relying on 'cookie', this commit
implements an op-log based 'CookieJar' which internally keeps track of
changes. The API is such that changes are only observable through
specialized '_pending()' methods.
2020-10-14 21:37:16 -07:00
Sergio Benitez 2f330d2967 Allow return type of '#[launch]' fn to be elided. 2020-10-12 22:32:02 -07:00
Sergio Benitez 092e03f720 Generate a proxy structure for better namespacing.
Prior to this commit, it was impossible to 'use' a route from a separate
namespace for use in a 'routes!' macro. Naturally, this was a common
source of confusion amongst users. This commit obviates this deficiency
by generating a "proxy" structure that can be imported and converted
into a 'Route'/'Catcher' or their static variants.

This change is largely backwards compatible but can break existing code
when routes are named identically to other types in the namespace.
2020-10-12 22:11:44 -07:00
Edwin Svensson 29f4726127 Fix typo in 'Form::into_inner' docs: unclosed codeblock. 2020-10-11 12:49:18 -07:00
Cezar Halmagean 2d1d7e8c89 Fix typo in requests guide: 'A' -> 'a'. 2020-10-11 12:48:09 -07:00
Howard Su 2040693dab Add missing explicit lifetime parameter to `PasteId<'_>` in pastebin guide. 2020-10-11 12:45:07 -07:00