Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LocalForm to make testing with form data more ergonomic #1605

Closed
wants to merge 286 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
286 commits
Select commit Hold shift + click to select a range
089c3c7
Uniformly implement utility traits on URI types.
SergioBenitez Jun 10, 2021
3e34752
Improve guard forward and failure logs.
SergioBenitez Jun 10, 2021
b0ad1bc
Fix typo in guide: 'mechnisms' -> 'mechanisms'.
thibaudmartinez Jun 10, 2021
f877945
Clarify explanation of reinterpreted request methods in the requests …
paulsmith Jun 10, 2021
a798161
Fix link to the JSON example in the requests guide.
t-eckert Jun 10, 2021
9661825
Fix typo in requests guide: 'the' -> 'then'.
YohannesKifle Jun 14, 2021
cd65a60
Fix typos in fairings guide: 'are are', 'build' -> 'built'.
ShallmentMo Jun 13, 2021
c2c5fdc
Fix typo in configuration guide: 'it's' -> 'its'.
3point2 Jun 11, 2021
129297e
Fix a word in the 'Data::peek' docs: 'max' -> 'min'.
timando Jun 10, 2021
64fe4db
Fix Responder documentation: remove an outdated reference to 'Future'.
timando Jun 15, 2021
da40055
Fix a few minor mistakes in the guide.
paulvt Jun 15, 2021
507b785
Add missing documentation for the `run()` method generated by `#[data…
JarvisCraft Jun 16, 2021
75526b6
Update UI tests for latest stable.
jebrosen Jun 18, 2021
77da270
Always disable colors if requested or unavailable.
SergioBenitez Jun 19, 2021
cacc16d
Use Figment's 'Value' in contrib templating.
SergioBenitez Jun 19, 2021
3f8fd7c
Drop sender to prevent async client read deadlock.
SergioBenitez Jun 25, 2021
1734af4
Use 'RelativePathBuf' as 'Config.temp_dir' type.
SergioBenitez Jun 25, 2021
4fd2f62
Update GitHub issue templates.
SergioBenitez Jun 25, 2021
c87a912
Use configured database pool timeout on pool init.
SergioBenitez Jun 26, 2021
b2c1048
Visiting internal nodes in form field validator.
SergioBenitez Jun 26, 2021
88d671c
Add Markdown (text/markdown) as a known media type.
SergioBenitez Jun 26, 2021
155da2b
Fix 'TempFile' data guard warning formatting.
SergioBenitez Jun 26, 2021
ce45488
Warn, don't error, if remote hangs up.
SergioBenitez Jun 26, 2021
4dadc3c
Improve 'Responder' API docs.
SergioBenitez Jun 26, 2021
ff3044c
Support lifetime bounds in typed stream macros.
SergioBenitez Jun 26, 2021
a4b6913
Fix wording in 'config' docs.
SergioBenitez Jun 26, 2021
95b5549
Fix link to 'FromForm' derive in 'FromForm' docs.
SergioBenitez Jun 26, 2021
3fa572c
Allow 'len()' form field validations on 'Capped'.
SergioBenitez Jun 26, 2021
f251c3f
Add 'Missing', 'IndexFile' 'FileServer' options.
SergioBenitez Jun 26, 2021
da6c8f3
Use higher contrast emojis for routes, catchers.
SergioBenitez Jun 26, 2021
c3b68ff
Improve text on site index page.
SergioBenitez Jun 27, 2021
5b8d076
Reexport 'serde::json::to_value()'.
SergioBenitez Jun 29, 2021
58966be
Impl std traits, 'UriDisplay<Query>' for 'Json'.
SergioBenitez Jun 29, 2021
ea062b8
Expose 'serde::msgpack::to_vec()' methods.
SergioBenitez Jun 29, 2021
7e9b587
Impl std traits, 'UriDisplay<Query>' on 'MsgPack'.
SergioBenitez Jun 29, 2021
c6d9cd5
Impl 'UriDisplay' for 'Vec', maps, nonzero ints.
SergioBenitez Jun 29, 2021
990e219
Automatically discover 'Responder' generic bounds.
SergioBenitez Jun 29, 2021
004189a
Explicitly mention multipart support in guide.
SergioBenitez Jun 29, 2021
8d79da5
Support type generics, unit structs in 'FromForm'.
SergioBenitez Jun 29, 2021
77c245f
Add "Wrapping Validators" section to forms guide.
SergioBenitez Jun 29, 2021
e53748f
Fix order of indices in 'FromForm' map notes.
SergioBenitez Jun 29, 2021
426fde8
Impl 'Len' field validator for 'Json', 'MsgPack'.
SergioBenitez Jun 29, 2021
3cd7296
Mark 'form::ErrorKind' 'non_exhaustive'.
SergioBenitez Jun 29, 2021
d86a76e
Add configurable TLS ciphersuite preferences.
SergioBenitez Jun 29, 2021
bafe0b3
Propagate TLS ciphersuite config to rustls.
SergioBenitez Jun 29, 2021
f49663e
Ensure launch occurs with minimal ciphersuites.
SergioBenitez Jun 29, 2021
262464b
Support all generics in 'UriDisplay' derive.
SergioBenitez Jun 30, 2021
5b28126
Add 'RawStr::percent_encode_bytes()'.
SergioBenitez Jun 30, 2021
be7ff6f
Pass type mapper directly in 'Responder' derive.
SergioBenitez Jun 30, 2021
6c34405
Add 'rocket::serde:json::to_string()' functions.
SergioBenitez Jun 30, 2021
9020d54
Fix 'UriDisplay<Query>' 'Json', 'MsgPack', impls.
SergioBenitez Jun 30, 2021
7aabe7a
Add 'context!' for ad-hoc templating contexts.
Flying-Toast May 13, 2021
a4b2d7e
Fix link to 'rocket_dyn_templates' git repository.
Tiwalun Jun 10, 2021
2bab3bd
Fix git repository link to 'rocket_sync_db_pools'.
SergioBenitez Jun 30, 2021
15a7cf3
Don't ignore 'launch()' result in guide overview.
SergioBenitez Jun 30, 2021
403d702
Make '<String as FromParam>::Error' 'Infallible'.
JarvisCraft Jun 11, 2021
592ed90
Impl 'Responder' for 'Arc<T>', 'Box<T>'.
udoprog Jun 12, 2021
cc665e8
Check response status in guide form tests.
Heliozoa Jun 12, 2021
8fc4096
Update IRC links to Libera (irc.libera.chat).
ijackson Jun 12, 2021
377d480
Fix typo in 'Sentinel' docs: 'INner' -> 'Inner'.
JockeTF Jun 18, 2021
ddf7654
Fix guide typo: "deserialzies" -> "deserializes".
MultisampledNight Jun 23, 2021
c9ac822
Impl 'std::Error' for 'serde::json::Error'.
ThouCheese Jun 26, 2021
27ff741
Apply clippy suggestions.
MikailBag Jun 30, 2021
7588555
Doctest core feature matrix with '--no-run'.
SergioBenitez Jul 1, 2021
2eab04c
Run core feature testing on nightly.
SergioBenitez Jul 1, 2021
d260195
Fix header level of "Within Guards" in guide.
SergioBenitez Jul 1, 2021
83c2c82
Allow named field generics in 'UriDisplay' derive.
SergioBenitez Jul 1, 2021
c59465b
Make 'FileName' danger more pronounced.
SergioBenitez Jul 2, 2021
b9acf25
Add type-safe 'Host' type, 'Request::host()'.
SergioBenitez Jul 2, 2021
5b47164
Make '&Host' a request guard.
SergioBenitez Jul 2, 2021
009ef97
Sync core 'UriDisplay' and 'FromUriParam' impls.
SergioBenitez Jul 2, 2021
7f8f6e4
Impl 'FromUriParam' for 'Json'.
SergioBenitez Jul 2, 2021
e6a679a
Warn on more deprecated config keys and profiles.
SergioBenitez Jul 2, 2021
ea64d00
Remove latent 'dbg!()' in templating tests.
SergioBenitez Jul 2, 2021
6b751da
Properly propagate profile to 'Config' on ignite.
SergioBenitez Jul 2, 2021
58c1368
Warn on launch if a custom runtime is detected.
SergioBenitez Jul 2, 2021
ff6340e
Fix 'context!()' typo: "supports" -> "supported".
SergioBenitez Jul 2, 2021
309e205
Make 'MediaType::with_params()' a builder method.
SergioBenitez Jul 4, 2021
4d2d109
Make 'tls' its own module.
SergioBenitez Jul 4, 2021
13590d1
Split TLS module into logical submodules.
SergioBenitez Jul 4, 2021
7ebff67
Rename 'remote_addr' to 'peer_address'.
SergioBenitez Jul 4, 2021
0f78171
Condition TLS config types on 'tls' feature.
SergioBenitez Jul 5, 2021
ec8196d
Restore 'doc(cfg)' labels for config items.
SergioBenitez Jul 5, 2021
fd99ff3
Don't store example keys and certs in repository.
SergioBenitez Jul 7, 2021
6153a2d
Initial implementation of mTLS.
SergioBenitez Jul 9, 2021
b134c02
Complete mTLS implementation.
SergioBenitez Jul 9, 2021
9ad0d50
Bring back generated TLS keys, used by tests.
SergioBenitez Jul 9, 2021
d079aac
Add README to databases example.
SergioBenitez Jul 12, 2021
d31e219
Initial implementation of async DB pooling.
jebrosen May 31, 2021
438ecea
Introduce async database pools: 'rocket_db_pools'.
SergioBenitez Jul 9, 2021
5cb0e91
Remove faulty 'glob' arg in codegen UI tests.
SergioBenitez Jul 18, 2021
97a7890
Add 'rocket_db_pools' UI tests.
SergioBenitez Jul 18, 2021
5caeeac
Prefix 'content' responder names with 'Raw'.
SergioBenitez Jul 20, 2021
e93af5c
Point to 'mtls::Certificate' in mTLS config docs.
SergioBenitez Jul 20, 2021
fe40ed8
Update UI tests for latest nightly.
SergioBenitez Jul 21, 2021
6b1c916
Fix typos in 'DataField' API documentation.
Garmelon Jul 7, 2021
57f115c
Fix typo in 'XssFilter' API documentation: 'enorce' -> 'enforce'.
goncalor Jul 12, 2021
22b775b
Fix typo in fairings guide: missing 'of the'.
jrheard Jul 15, 2021
74fd9f5
Fix 'ROCKET_CLI_COLORS' example in getting started guide: 'off' -> 'f…
silas Jul 4, 2021
e8a6074
Fix typo in requests guide: 'Synax' -> 'Syntax'.
jdkaplan Jul 25, 2021
38234d4
Update UI tests for latest stable.
jebrosen Aug 1, 2021
3741aa0
Update UI tests for latest nightly.
jebrosen Aug 1, 2021
adfdb04
Clarify 'Options::Missing' exception in 'FileServer'.
SergioBenitez Jul 21, 2021
be32d27
Track caller in 'mount' and 'register' calls.
SergioBenitez Jul 21, 2021
57399f4
Remove unused 'parking_lot' 'http' dependency.
SergioBenitez Jul 28, 2021
0bf14a3
Propagate 'log_level' to SQLx logs.
SergioBenitez Aug 8, 2021
ffa01c5
Remove unused 'mime' dependency.
SergioBenitez Aug 8, 2021
591d050
Use 'hyper' instead of 'http' where possible.
SergioBenitez Aug 8, 2021
5eec7c4
Add missing newline for better doc rendering.
SergioBenitez Aug 8, 2021
7ff6368
Don't enable unused 'futures' features.
SergioBenitez Aug 8, 2021
47aa6f8
Update 'devise', fix 'Responder' derive generics.
SergioBenitez Aug 8, 2021
4682426
Update 'time' to 0.3, 'cookie' to 0.16.
SergioBenitez Aug 20, 2021
1e89178
Add 0.5 migration guide, FAQ to site docs.
SergioBenitez Aug 20, 2021
fc54ad4
Update UI tests for latest nightly.
SergioBenitez Aug 20, 2021
12f2cde
Increase diesel DB example timeout for CI.
SergioBenitez Aug 20, 2021
b3b1f2f
Use cardinality-agnostic wording in error format.
SergioBenitez Aug 25, 2021
5a666f7
Display launch address using 'SocketAddr' fmt.
breard-r Aug 3, 2021
8f0032e
Workaround 'rustc' bug, compiling more async code.
jakubdabek Aug 21, 2021
71a0675
Add missing ']' in forms guide.
hiyoko3m Aug 9, 2021
336c50d
Fix markdown word wrap.
SergioBenitez Aug 25, 2021
ec4b16f
Clean up upgrade guide, FAQ. Mention FAQ more.
SergioBenitez Aug 29, 2021
fd98835
Update 'handlebars' to 4.0.
sunng87 Jun 10, 2021
a8b9d3a
Fix docs for handlebars update.
SergioBenitez Aug 30, 2021
a8b3818
Add 'Connection::into_inner()' in 'db_pools'.
SergioBenitez Aug 30, 2021
7754136
Fix typo in guide overview.
johananl Sep 5, 2021
706ea8e
Update codebase for latest nightly and stable.
SergioBenitez Feb 16, 2022
ac5aa36
Update dependencies in core to latest versions.
SergioBenitez Feb 16, 2022
2bd83f1
Update 'deadpool' dependencies in 'db_pools'.
SergioBenitez Feb 16, 2022
d0af5f8
Update 'mongodb' to '2' in 'db_pools'.
SergioBenitez Feb 16, 2022
b33c773
Update 'cookie' to '0.16'.
kolbma Jan 17, 2022
4c918dc
Remove 'CookieJar::get_private_pending()'.
kolbma Jan 17, 2022
1238d04
Explicitly import 'Result' in 'context!'.
Misterio77 Oct 28, 2021
bdbde2f
Update 'x509-parser' to 0.12.
SergioBenitez Feb 22, 2022
9cd57e2
Update 'x509-parser' to 0.13.
SergioBenitez Feb 22, 2022
df21e61
Update 'rustls' to 0.20.
SergioBenitez Feb 22, 2022
20b37b3
Add 'includeSubdomains' in HSTS preload header.
SergioBenitez Feb 23, 2022
363eeab
Explicitly doc enabling 'json' feature in guide.
the10thWiz Jul 20, 2021
64bd6a2
Add sqlite aux files to gitignore.
SergioBenitez Feb 23, 2022
ea8aa75
Fix flash message display in todo example.
xelivous Feb 23, 2022
2705e11
Fix typo in suggestion issue template.
Feb 23, 2022
bbb2798
Use 'matches!' macro where possible.
Feb 23, 2022
40020d4
Log launch messages at info level.
davidv1992 Sep 21, 2021
eb2c540
Fix 'form' data limit name in configuration guide.
JoshuaNitschke Sep 9, 2021
f4b1f38
Fix spacing in 'overview' code examples.
j127 Sep 14, 2021
fe7075f
Fix link to OWASP path traversal docs in guide.
xypnox Sep 26, 2021
89fbed5
Use docstring '///' comment in 'Responder' docs.
Aurora2500 Feb 5, 2022
8acd7e2
Fix 'observe' and 'retrieve' typos in cookie docs.
w3irdrobot Oct 11, 2021
c7d8f37
Use fully working examples in dyn_templates.
SergioBenitez Mar 3, 2022
6390270
Fix typo: 'Tera' -> 'Handlebars'.
jurf Nov 30, 2021
409ed71
Update UI tests for latest stable.
SergioBenitez Mar 7, 2022
ff45725
Implement and log with panic-free 'write_out!'.
kolbma Jan 17, 2022
845960c
Make HTTP/2 optional via 'http2' feature.
edgarogh Feb 23, 2022
096e0b3
Log HTTP/2 availability at start-up.
SergioBenitez Mar 8, 2022
7ad1677
Fix parsing docs for 'Lenient'.
SergioBenitez Mar 9, 2022
baa194c
Use 'print' for logging in debug.
SergioBenitez Apr 14, 2022
f3931c1
Rework 'local_cache!' so it returns unique refs.
SergioBenitez Apr 19, 2022
ddb3a74
Disallow ':' in `PathBuf` guard on Windows.
SergioBenitez Apr 19, 2022
833666c
Fix UI tests for latest stable, nightly.
SergioBenitez Apr 19, 2022
faa78b5
Set 'RUSTC_BOOTSTRAP' to for '--no-run' on stable.
SergioBenitez Apr 19, 2022
e25e9db
Add 'must_use' to 'Rocket'.
SergioBenitez Apr 19, 2022
a5626da
Fix 'Segments::to_path_buf()' on Windows.
SergioBenitez Apr 19, 2022
b20904b
Allow 'unused_doc_comments' on generated doctests.
SergioBenitez Apr 19, 2022
7daad7c
Use non-deprecated 'rmp_serde::from_slice'.
SergioBenitez Apr 19, 2022
e3e8c73
Implement 'Eq' for 'MediaType', 'ContentType'.
SergioBenitez Apr 19, 2022
ac5237b
Migrate Rocket to Rust 2021 edition.
KamilaBorowska Mar 19, 2022
a50fe69
Use new 2021 edition functionality.
KamilaBorowska Apr 19, 2022
6ff6144
Consider form parsing strategy for 'Vec', 'Map'.
SergioBenitez Apr 21, 2022
a23d53b
Update 'uuid' to 1.0.
SergioBenitez Apr 27, 2022
acb5f85
Update 'rustls-pemfile' to 1.0.
SergioBenitez Apr 27, 2022
ebcc935
Fix SSE heartbeat so it never interrupts events.
SergioBenitez Apr 27, 2022
81ea46a
Fix UI tests.
SergioBenitez Apr 27, 2022
9dc5c0e
Enable TCP_NODELAY on TCP-based connections.
SergioBenitez Apr 28, 2022
0f20c6e
Fully 'drop()' I/O struct in 'CancellableIo'.
SergioBenitez Apr 30, 2022
b0e24c5
Rework TLS listener/connection implementations.
SergioBenitez May 3, 2022
7f13037
Avoid platform dependent errors in UI tests.
SergioBenitez May 3, 2022
391ce6c
Avoid more platform dependent errors in UI tests.
SergioBenitez May 3, 2022
051422e
Allow '[' and ']' in URI paths.
SergioBenitez May 4, 2022
d301dce
Downgrade URI discord debug assertion to warning.
SergioBenitez May 4, 2022
01f0648
Switch to upstream 'tokio-rustls'.
SergioBenitez May 4, 2022
fd4d31e
Synchronize 'db_pools' docs with libraries.
SergioBenitez May 4, 2022
f533c2d
Improve and clarify 'Rocket' phase docs.
SergioBenitez May 4, 2022
99aa02d
Improve unrecognized TLS key header error message.
awoimbee Mar 30, 2022
58f571d
Fix 'FromRequest' docs typo: 'request' -> 'route'.
maccesch Apr 28, 2022
7d1ab53
Add clarity around 'serde' re-exports.
SergioBenitez May 6, 2022
e4f73a5
Revamp shutdown to recover shutdown 'Rocket'.
SergioBenitez May 6, 2022
65866a5
Update FAQ.
SergioBenitez May 7, 2022
aef70d9
Introduce shutdown fairings.
SergioBenitez May 7, 2022
dd026a3
Add 'rocket::execute()'.
SergioBenitez May 7, 2022
09a852b
Unhide 'http' exports that shouldn't be hidden.
SergioBenitez May 8, 2022
1268c12
Revamp pastebin tutorial for Rocket v0.5.
SergioBenitez May 8, 2022
94f76a0
Fix 'PasteId' 'use' in pastebin tutorial.
SergioBenitez May 8, 2022
5b29b66
Update CHANGELOG for rc.2, missing rc.1 changes.
SergioBenitez Apr 21, 2022
8d56107
Update state guide for 'rocket_db_pools'.
SergioBenitez May 9, 2022
814b216
Print more variables from 'config.sh -p'.
SergioBenitez May 9, 2022
d8379ea
Add 'db_pools' to 'config.sh' crates.
SergioBenitez May 9, 2022
fee050a
Update build benchmark in FAQ.
SergioBenitez May 9, 2022
4b00bc9
Fix broken anchor link in config guide.
SergioBenitez May 9, 2022
f39b174
New version: 0.5.0-rc.2.
SergioBenitez May 9, 2022
507b7fd
Don't set master as current release.
SergioBenitez May 9, 2022
d265b8a
Fix typo in 'Rocket' docs: iterior -> interior.
hadronized May 9, 2022
70df07b
Fix minor typos in rc.2 release docs.
SergioBenitez May 9, 2022
929cb37
Mention removal of `content::Custom` in CHANGELOG.
SergioBenitez May 10, 2022
83e0120
Impl 'Responder' for 'Box<T: Responder + Sized>'.
SergioBenitez May 10, 2022
2cedb19
Update comment in 'Listener' sleep code.
SergioBenitez May 19, 2022
ec3d297
Enable 'cookie' 'secure' feature conditionally.
KamilaBorowska May 11, 2022
47e6404
Fix Rocket's dependency count in FAQ.
SergioBenitez May 19, 2022
a6bb698
Mark fns returning 'Rocket<Build>' 'must_use'.
SergioBenitez May 19, 2022
a621b8b
Update UI tests for latest stable rustc.
SergioBenitez May 19, 2022
4cc281c
Make 'form::ErrorKind' 'From' impl const generic.
the10thWiz May 19, 2022
35d15b1
Use '-q' (quiet) when running tests in CI.
SergioBenitez May 20, 2022
db2e0f4
Add 'Metadata::render()': direct template render.
SergioBenitez May 20, 2022
97df97e
Tolerate more timing issues in SSE heartbeat test.
SergioBenitez May 23, 2022
385231f
Fix typo in 0.5 upgrade guide.
kennethallen May 23, 2022
dc9b4ca
Fix 'clippy::needless_late_init' in form codegen.
KamilaBorowska May 11, 2022
bc38ebb
Add 'max_blocking' threads config value.
the10thWiz May 24, 2022
32cc97f
Salvage everything viable from bad requests.
the10thWiz May 24, 2022
a556023
Add pool retrieval to sync_db_pools.
SergioBenitez May 24, 2022
f20ba2b
Update 'sync_db_pools' UI tests for stable.
SergioBenitez May 25, 2022
e260a8e
Add MP3 (audio/mpeg) as a known media type.
j-tai Jun 2, 2022
91f4cec
Add several new known media types:
aaronleopold Jun 5, 2022
d898ea2
Avoid dropping 'Error' inside '#[launch]' future.
SergioBenitez Jun 21, 2022
267e7c7
Update UI tests for latest nightly.
SergioBenitez Jun 21, 2022
7853bc6
Fix guide page names to match search slugs.
SergioBenitez Jun 21, 2022
47862a4
Temporarily ignore Linux nightly CI failures.
SergioBenitez Jun 21, 2022
5ba6fd1
Make data guards eligible to be sentinels.
pennae Jun 20, 2022
21c7d5c
Gracefully shutdown database pools in 'db_pools'.
SergioBenitez Jul 13, 2022
c5ba267
Update UI tests for latest nightly, stable.
SergioBenitez Jul 14, 2022
aaaf135
Enable 'rust-src' component in CI.
SergioBenitez Jul 14, 2022
d750d6e
Fix links to upgrade guide.
SergioBenitez Jul 14, 2022
36a39ea
Clarify built-in request guard implementations.
SergioBenitez Jul 18, 2022
991a72d
Fix typo in production readiness FAQ.
fxsn Jul 24, 2022
df7942d
Fix typo in configuration guide.
charlax Jul 19, 2022
a6265fc
Fix typo in getting started guide.
rubiagatra Jul 16, 2022
f24a068
Fix 'Limits' deserialization.
kvinwang Jul 18, 2022
7c3195b
Silence false positive warnings.
SergioBenitez Aug 5, 2022
6b477d2
Update 'rust-cache' GitHub action to v2.
SergioBenitez Aug 5, 2022
28594a4
Implement 'FromForm' for 'Arc<T>'.
SergioBenitez Aug 30, 2022
d96dc8e
Always log launch message.
SergioBenitez Aug 30, 2022
f1b146d
Update UI tests for latest nightly, stable.
SergioBenitez Aug 31, 2022
24f7200
Include stable rust-src diagnostics.
SergioBenitez Sep 1, 2022
cb55842
Update 'sync_db_pools' UI tests.
SergioBenitez Sep 14, 2022
8839b44
Update diesel to 2.0, sqlx to 0.6.
Jun 21, 2022
ca1e599
Update database driver version numbers in docs.
SergioBenitez Sep 18, 2022
cde712b
Update notify to 5.0.
jacobsimpson Sep 17, 2022
b82b592
Fix log indentation.
SergioBenitez Sep 24, 2022
5371651
Update UI tests for latest nightly.
SergioBenitez Nov 9, 2022
78d23ff
Add failing form validation test cases.
ChristofferEnne Nov 11, 2022
3a3c136
Fix error field names in 'FromForm' derive.
SergioBenitez Nov 12, 2022
73c27f0
Report as many form errors as possible.
SergioBenitez Nov 12, 2022
cb8f5a6
Update UI tests for nightly.
SergioBenitez Nov 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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.
SergioBenitez authored and ELD committed Dec 27, 2022
commit cacc16dc5afb7d716f4de8c66b65fcda24653b35
2 changes: 0 additions & 2 deletions contrib/dyn_templates/Cargo.toml
Original file line number Diff line number Diff line change
@@ -16,8 +16,6 @@ tera = ["tera_"]
handlebars = ["handlebars_"]

[dependencies]
serde = "1.0"
serde_json = "1.0.26"
glob = "0.3"
notify = "4.0.6"
normpath = "0.3"
2 changes: 1 addition & 1 deletion contrib/dyn_templates/src/engine.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::path::Path;
use std::collections::HashMap;

use serde::Serialize;
use rocket::serde::Serialize;

use crate::TemplateInfo;

12 changes: 4 additions & 8 deletions contrib/dyn_templates/src/handlebars_templates.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::path::Path;

use serde::Serialize;
use rocket::serde::Serialize;

use crate::engine::Engine;
pub use crate::handlebars::Handlebars;
@@ -29,12 +29,8 @@ impl Engine for Handlebars<'static> {
return None;
}

match Handlebars::render(self, name, &context) {
Ok(string) => Some(string),
Err(e) => {
error_!("Error rendering Handlebars template '{}': {}", name, e);
None
}
}
Handlebars::render(self, name, &context)
.map_err(|e| error_!("Handlebars: {}", e))
.ok()
}
}
24 changes: 10 additions & 14 deletions contrib/dyn_templates/src/lib.rs
Original file line number Diff line number Diff line change
@@ -118,17 +118,15 @@
//!
//! Templates are rendered with the `render` method. The method takes in the
//! name of a template and a context to render the template with. The context
//! can be any type that implements [`Serialize`] from [`serde`] and would
//! serialize to an `Object` value.
//! can be any type that implements [`Serialize`] and would serialize to an
//! `Object` value.
//!
//! ## Automatic Reloading
//!
//! In debug mode (without the `--release` flag passed to `cargo`), templates
//! will be automatically reloaded from disk if any changes have been made to
//! the templates directory since the previous request. In release builds,
//! template reloading is disabled to improve performance and cannot be enabled.
//!
//! [`Serialize`]: serde::Serialize

#![doc(html_root_url = "https://api.rocket.rs/v0.5-rc/rocket_dyn_templates")]
#![doc(html_favicon_url = "https://rocket.rs/images/favicon.ico")]
@@ -166,18 +164,16 @@ pub use self::metadata::Metadata;
use self::fairing::TemplateFairing;
use self::context::{Context, ContextManager};

use serde::Serialize;
use serde_json::{Value, to_value};

use std::borrow::Cow;
use std::path::PathBuf;
use std::error::Error;

use rocket::{Rocket, Orbit, Ignite, Sentinel};
use rocket::request::Request;
use rocket::fairing::Fairing;
use rocket::response::{self, Responder};
use rocket::http::{ContentType, Status};
use rocket::figment::{value::Value, error::Error};
use rocket::serde::Serialize;

const DEFAULT_TEMPLATE_DIR: &str = "templates";

@@ -191,7 +187,7 @@ const DEFAULT_TEMPLATE_DIR: &str = "templates";
#[derive(Debug)]
pub struct Template {
name: Cow<'static, str>,
value: Option<Value>
value: Result<Value, Error>
}

#[derive(Debug)]
@@ -299,7 +295,7 @@ impl Template {
/// }
/// ```
pub fn try_custom<F: Send + Sync + 'static>(f: F) -> impl Fairing
where F: Fn(&mut Engines) -> Result<(), Box<dyn Error>>
where F: Fn(&mut Engines) -> Result<(), Box<dyn std::error::Error>>
{
TemplateFairing { callback: Box::new(f) }
}
@@ -325,7 +321,7 @@ impl Template {
pub fn render<S, C>(name: S, context: C) -> Template
where S: Into<Cow<'static, str>>, C: Serialize
{
Template { name: name.into(), value: to_value(context).ok() }
Template { name: name.into(), value: Value::serialize(context) }
}

/// Render the template named `name` with the context `context` into a
@@ -386,13 +382,13 @@ impl Template {
let info = ctxt.templates.get(name).ok_or_else(|| {
let ts: Vec<_> = ctxt.templates.keys().map(|s| s.as_str()).collect();
error_!("Template '{}' does not exist.", name);
info_!("Known templates: {}", ts.join(", "));
info_!("Known templates: {}.", ts.join(", "));
info_!("Searched in {:?}.", ctxt.root);
Status::InternalServerError
})?;

let value = self.value.ok_or_else(|| {
error_!("The provided template context failed to serialize.");
let value = self.value.map_err(|e| {
error_!("Template context failed to serialize: {}.", e);
Status::InternalServerError
})?;

15 changes: 4 additions & 11 deletions contrib/dyn_templates/src/tera_templates.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::path::Path;
use std::error::Error;

use serde::Serialize;
use rocket::serde::Serialize;

use crate::engine::Engine;

@@ -42,16 +42,9 @@ impl Engine for Tera {
return None;
};

let tera_ctx = match Context::from_serialize(context) {
Ok(ctx) => ctx,
Err(_) => {
error_!(
"Error generating context when rendering Tera template '{}'.",
name
);
return None;
}
};
let tera_ctx = Context::from_serialize(context)
.map_err(|e| error_!("Tera context error: {}.", e))
.ok()?;

match Tera::render(self, name, &tera_ctx) {
Ok(string) => Some(string),
36 changes: 33 additions & 3 deletions contrib/dyn_templates/tests/templates.rs
Original file line number Diff line number Diff line change
@@ -126,6 +126,21 @@ mod tera_tests {
assert_eq!(template, Some(ESCAPED_EXPECTED.into()));
}

// u128 is not supported. enable when it is.
// #[test]
// fn test_tera_u128() {
// const EXPECTED: &'static str
// = "\nh_start\ntitle: 123\nh_end\n\n\n1208925819614629174706176\n\nfoot\n";
//
// let client = Client::debug(rocket()).unwrap();
// let mut map = HashMap::new();
// map.insert("title", 123);
// map.insert("number", 1u128 << 80);
//
// let template = Template::show(client.rocket(), "tera/txt_test", &map);
// assert_eq!(template, Some(EXPECTED.into()));
// }

#[test]
fn test_template_metadata_with_tera() {
let client = Client::debug(rocket()).unwrap();
@@ -151,11 +166,11 @@ mod handlebars_tests {
use rocket::http::Status;
use rocket::local::blocking::Client;

const EXPECTED: &'static str
= "Hello _test_!\n\n<main> &lt;script /&gt; hi </main>\nDone.\n\n";

#[test]
fn test_handlebars_templates() {
const EXPECTED: &'static str
= "Hello _test_!\n\n<main> &lt;script /&gt; hi </main>\nDone.\n\n";

let client = Client::debug(rocket()).unwrap();
let mut map = HashMap::new();
map.insert("title", "_test_");
@@ -166,6 +181,21 @@ mod handlebars_tests {
assert_eq!(template, Some(EXPECTED.into()));
}

// u128 is not supported. enable when it is.
// #[test]
// fn test_handlebars_u128() {
// const EXPECTED: &'static str
// = "Hello 123!\n\n<main> 1208925819614629174706176 </main>\nDone.\n\n";
//
// let client = Client::debug(rocket()).unwrap();
// let mut map = HashMap::new();
// map.insert("title", 123);
// map.insert("number", 1u128 << 80);
//
// let template = Template::show(client.rocket(), "hbs/test", &map);
// assert_eq!(template, Some(EXPECTED.into()));
// }

#[test]
fn test_template_metadata_with_handlebars() {
let client = Client::debug(rocket()).unwrap();