Commit Graph

148 Commits

Author SHA1 Message Date
Sergio Benitez fe9fad339e Clean up connection pooling documentation. 2018-08-15 23:31:49 -07:00
Eric Dattore 60b9f06407 Implement connection pooling support in contrib.
Resolves #167.
2018-08-15 22:11:53 -07:00
Sergio Benitez 429c0dfeb6 Fix template fairing given 'ConfigError::Missing'. 2018-08-15 19:00:43 -07:00
Sergio Benitez 55459db773 Properly constrain 'serde_json' version. 2018-08-14 11:20:42 -07:00
Sergio Benitez d699827079 Reexport new 'serde_json::json_internal_vec' macro. 2018-08-14 09:53:04 -07:00
Sergio Benitez ec130f96ee Implement a 'StaticFiles' custom handler in contrib.
Closes #239.
2018-08-13 02:17:50 -07:00
Sergio Benitez 4098ddd92f Improve templates contrib test by reusing code. 2018-08-13 02:14:16 -07:00
Sean Stangl 9bf585496c Apply more Clippy suggestions. 2018-08-11 23:41:35 -07:00
Sergio Benitez 0612c644ad Fix typo in 'Template::finalize()' docstring. 2018-08-11 23:17:22 -07:00
Sergio Benitez f941b1310b Improve template engine customization docs. 2018-08-10 23:29:12 -07:00
jeb 491b04cf5a Implement template auto-reload.
Resolves #163.
2018-08-10 23:29:12 -07:00
Sergio Benitez 56c6a96f6a Overhaul URI types.
This is fairly large commit with several entangled logical changes.

The primary change in this commit is to completely overhaul how URI
handling in Rocket works. Prior to this commit, the `Uri` type acted as
an origin API. Its parser was minimal and lenient, allowing URIs that
were invalid according to RFC 7230. By contrast, the new `Uri` type
brings with it a strict RFC 7230 compliant parser. The `Uri` type now
represents any kind of valid URI, not simply `Origin` types. Three new
URI types were introduced:

  * `Origin` - represents valid origin URIs
  * `Absolute` - represents valid absolute URIs
  * `Authority` - represents valid authority URIs

The `Origin` type replaces `Uri` in many cases:

  * As fields and method inputs of `Route`
  * The `&Uri` request guard is now `&Origin`
  * The `uri!` macro produces an `Origin` instead of a `Uri`

The strict nature of URI parsing cascaded into the following changes:

  * Several `Route` methods now `panic!` on invalid URIs
  * The `Rocket::mount()` method is (correctly) stricter with URIs
  * The `Redirect` constructors take a `TryInto<Uri>` type
  * Dispatching of a `LocalRequest` correctly validates URIs

Overall, URIs are now properly and uniformly handled throughout Rocket's
codebase, resulting in a more reliable and correct system.

In addition to these URI changes, the following changes are also part of
this commit:

  * The `LocalRequest::cloned_dispatch()` method was removed in favor of
    chaining `.clone().dispatch()`.
  * The entire Rocket codebase uses `crate` instead of `pub(crate)` as a
    visibility modifier.
  * Rocket uses the `crate_visibility_modifier` and `try_from` features.

A note on unsafety: this commit introduces many uses of `unsafe` in the
URI parser. All of these uses are a result of unsafely transforming byte
slices (`&[u8]` or similar) into strings (`&str`). The parser ensures
that these casts are safe, but of course, we must label their use
`unsafe`. The parser was written to be as generic and efficient as
possible and thus can parse directly from byte sources. Rocket, however,
does not make use of this fact and so would be able to remove all uses
of `unsafe` by parsing from an existing `&str`. This should be
considered in the future.

Fixes #443.
Resolves #263.
2018-07-29 00:17:33 -07:00
Sergio Benitez 49365d5fdf Update 'handlebars' to 1.0. 2018-07-22 21:59:40 -07:00
jeb 0c80217289 Fix various spelling and grammar issues in core and contrib. 2018-07-20 22:14:58 -06:00
Sergio Benitez 5acb08a026 Make contrib MsgPack tests actually run. 2018-07-10 17:08:58 -07:00
Sergio Benitez 0045486227 Implement Serialize + Deserialize for contrib JsonValue. 2018-07-10 17:08:26 -07:00
Sergio Benitez 39c952f8eb Clean up 'TemplateMetadata' implementation. 2018-07-10 17:07:53 -07:00
Marc Mettke c381386098 Add 'TemplateMetadata' request guard to contrib.
The request guard allows a user to query information about loaded
templates. In particular, a user can check whether a template was
loaded.
2018-07-10 15:11:43 -07:00
Beatriz Rizental 965c90afc9 Add 'log = off' config option to disable all logging. 2018-07-07 18:12:25 -07:00
Sergio Benitez 88d3b59c71 Use 'or_else' to tidy up 'Template::show()'. 2018-07-02 19:14:17 -07:00
Sergio Benitez 397a646dcf Fix conditional compilation for contrib templates tests. 2018-06-03 20:42:15 +02:00
Sergio Benitez 1e8e4cc553 Fix Cargo.toml path to README. 2018-06-03 19:39:32 +02:00
Sergio Benitez f171dc9d09 Reorganize repository.
The directory structure has changed to better isolate crates serving
core and contrib. The new directory structure is:

  contrib/
    lib/ - the contrib library
  core/
    lib/ - the core Rocket library
    codegen/ - the "compile extension" codegen library
    codegen_next/ - the new proc-macro library
  examples/ - unchanged
  scripts/ - unchanged
  site/ - unchanged

This commit also removes the following files:

  appveyor.yml - AppVeyor (Rust on Windows) is far too spotty for use
  rustfmt.toml - rustfmt is, unfortunately, not mature enough for use

Finally, all example Cargo crates were marked with 'publish = false'.
2018-06-03 18:44:38 +02:00
Sergio Benitez a040ddd122 Fix links to configuration guide. 2018-05-13 23:33:42 -07:00
Marshall Bowers b876f233a8 Replace 'macro_reexport' with 'pub use'. 2018-05-04 23:36:09 -07:00
Kyle Clemens 105137a46d Rename 'UUID' to 'Uuid' in 'rocket_contrib'. 2018-04-14 20:07:50 -07:00
messense fa217082fd Preallocate 512 byte buffer for JSON deserialization. 2018-04-08 17:25:35 -07:00
Sergio Benitez 9dcb285799 Remove stabilized feature gates.
These are:

  * i128_type
  * conservative_impl_trait
  * never_type
2018-04-03 21:52:33 -07:00
Sergio Benitez 8e46530a39 Update 'handlebars' to 0.32. 2018-02-25 20:12:53 -08:00
Sergio Benitez b76a1ef8b9 Update 'uuid' dependency to '0.6'.
Resolves #565.
2018-02-21 00:57:39 -08:00
messense ae8e9025d2 Eagerly read JSON data for deserialization.
Issue #547 identified a performance issue when serde's 'from_reader' is
used to deserialize incoming data. Using 'from_str' resolves the issue.
This commit swaps a use of 'from_reader' in favor of 'from_str' in
rocket_contrib's 'Json' implementation.

Additionally, this commit ensures that un-deserialized JSON data is
discarded as long as it is within the JSON data limit.

Closes #562.
2018-02-19 02:58:37 -08:00
Sergio Benitez 3a8d0e8a9a Dynamically increase/decrease log level at launch.
This commit modifies the internal logger so that launch messages are
emitted with the proper "info" level. The approach is to temporarily
weaken the log level to "normal" during launch and reset it to the
user's setting after launching.

This commit also upgrades to 'log' 0.4.

Fixes #553.
2018-01-29 13:16:04 -08:00
Sergio Benitez f2331a831a Update handlebars to 0.30, tera to 0.11. 2018-01-23 18:53:55 -08:00
Sergio Benitez f7e5c105ee Improve documentation on accessing templating engines. 2017-12-28 22:57:49 -08:00
Jeb Rosen f9f1ed75cd Have 'Template::show()' take an '&Rocket'.
This completes the effort started in #431, allowing for direct
customization of the underlying templating engines of 'Template'.

Resolves #64. Closes #234. Closes #431. Closes #500.
2017-12-28 19:57:13 -08:00
Ning Sun d79cb9d8f0 Add 'Template::custom()' to customize templating engines. 2017-12-28 19:49:55 -08:00
Sergio Benitez aad97e6be0 Use correct rustdoc 'html_root_url'.
Fixes #474.
2017-11-22 10:58:20 -08:00
Sergio Benitez f87b46d6c5 Fix incorrect emission of config errors from templates. 2017-11-17 12:24:33 -08:00
Sergio Benitez 16feedd563 Remove 'drop_types_in_const' feature: stabilized. 2017-09-14 22:39:19 -07:00
Sergio Benitez 2f84d4b18a Add 'Config::root_relative()'. Make TLS config paths root-relative.
Prior to this commit, relative paths to TLS PEM files were incorrectly
treated as being relative to the CWD as opposed to the Rocket config
file, when present. This commit resolves the issue.
2017-09-04 19:01:26 -07:00
Sergio Benitez 3ed0201c6e Remove unused 'extern crate's. 2017-08-31 17:03:47 -07:00
Sergio Benitez 7ce250b82f Update dependencies for ring 0.12. 2017-08-31 16:58:24 -07:00
Sergio Benitez a019f0d1f3 Use new 'JsonValue' type as return type of 'json!'.
Prior to this commit, a 'json!' invocation returned a value of type
'Value' from 'serde_json'. Because 'Value' does not implement
'Responder', most uses of 'json!' were wrapped in 'Json':
'Json(json!(..))`. By returning a crate-local 'JsonValue' type that
implements 'Responder', this repetition is resolved, and a 'json!' can
appear unwrapped.

This commit also removes the reexport of 'Value' from 'rocket_contrib'
as well as the default type of 'Value' for 'T' in 'Json<T>'.
2017-08-25 23:14:42 -07:00
Sergio Benitez 3f6c6fd576 Move to 0.4.0-dev on master. 2017-08-11 09:32:27 -07:00
Sergio Benitez 944eaa3e3c Emit all error messages from Tera on init failure.
Resolves #369.
2017-08-02 16:58:55 -07:00
Laurentiu Nicola 5f0583eb04 Don't skip over the first Tera error.
The first line in the Tera error messages is sometimes less useful,
but in other cases, like when the context is not a map or struct,
contains the complete description. As such, always include it, even if
the output is slightly uglier. Also don't append periods at the end
since some Tera messages already have them.
2017-07-26 23:32:35 -04:00
Sergio Benitez cdacda0896 New version: 0.3.0. 2017-07-14 11:30:48 -07:00
Sergio Benitez 897313730d Use TitleCase for all 'content::' struct names. 2017-07-12 15:21:45 -07:00
Sergio Benitez 65886c8c4e Rename 'contrib::JSON' to 'contrib::Json'. 2017-07-12 15:11:41 -07:00
Sergio Benitez 6050eb5169 Update for 2017-07-09. 'associated_consts' is stable. 2017-07-09 22:00:01 -07:00