Commit Graph

185 Commits

Author SHA1 Message Date
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
Sergio Benitez
b0612d7346 Enable features on docs.rs. 2017-06-30 02:41:00 -07:00
Sergio Benitez
539a7fc55b Remove 'struct_field_attributes' feature: it's been stabilized. 2017-06-19 17:44:01 -07:00
Sergio Benitez
6a7fde6d70 Initial cleanup of 'http' docs. Add 'handler::Outcome' docs.
This commit also changes the signature of the 'ContentType'
'from_extension" method so that it returns an 'Option<ContentType>' as
opposed to 'ContentType'.

This commit also disallows negative quality values in 'Accept' media
types.
2017-06-19 17:32:33 -07:00
Sergio Benitez
43a4028085 Use a less confusing version number during dev. 2017-06-18 02:25:26 -07:00
Sergio Benitez
876a8b8329 Make tera/handlebars rendering a little clearer. 2017-06-16 20:56:51 -07:00
Sergio Benitez
2bfb41d968 Update 'handlebars' and 'base64' dependencies. 2017-06-11 01:07:18 -07:00
Sergio Benitez
9a297f776b Tidy up broken links. Set 'html_root_url'. 2017-06-11 01:03:59 -07:00
Sergio Benitez
73fed03ef4 New version: 0.2.8. 2017-06-01 22:10:05 -07:00
Sergio Benitez
5f2b2ee3df New version: 0.2.7. 2017-05-26 20:37:54 -07:00
Sergio Benitez
9b955747e4 Remove config global state. Use Responder::respond_to.
This commit includes two major changes to core:

  1. Configuration state is no longer global. The `config::active()`
     function has been removed. The active configuration can be
     retrieved via the `config` method on a `Rocket` instance.

  2. The `Responder` trait has changed. `Responder::respond(self)` has
     been removed in favor of `Responder::respond_to(self, &Request)`.
     This allows responders to dynamically adjust their response based
     on the incoming request.

Additionally, it includes the following changes to core and codegen:

  * The `Request::guard` method was added to allow for simple
    retrivial of request guards.
  * The `Request::limits` method was added to retrieve configured
    limits.
  * The `File` `Responder` implementation now uses a fixed size body
    instead of a chunked body.
  * The `Outcome::of<R: Responder>(R)` method was removed while
    `Outcome::from<R: Responder(&Request, R)` was added.
  * The unmounted and unmanaged limits are more cautious: they will only
    emit warnings when the `Rocket` receiver is known.

This commit includes one major change to contrib:

  1. To use contrib's templating, the fairing returned by
     `Template::fairing()` must be attached to the running Rocket
     instance.

Additionally, the `Display` implementation of `Template` was removed. To
directly render a template to a `String`, the new `Template::show`
method can be used.
2017-05-19 03:29:08 -07:00
Lance Carlson
13061e9062 Update uuid dependency to 0.5. 2017-05-05 12:20:36 -07:00
Sergio Benitez
30fac32978 Upgrade dependencies to Serde 1.0.
Closes #272.
Resolves #273.
2017-04-24 17:37:18 -07:00
Sergio Benitez
7b48ca7103 Add optional input for IntoOutcome. Add mapper methods to Outcome.
This is a breaking change to `IntoOutcome`.

The MsgPack and JSON types now use `into_outcome` to generate the final
`Outcome` from their `FromData` implementations.

Resolves #98.
2017-04-18 21:56:21 -07:00
Roman Frołow
8555a0fad5 Fix typo in Template documentation: words -> works. 2017-04-18 19:52:18 -07:00
Sergio Benitez
1524b9a6b2 Document size limits. 2017-04-18 00:36:39 -07:00
Sergio Benitez
6dc21e5380 Add support for configurable size limits. 2017-04-18 00:25:13 -07:00
Sergio Benitez
e6bbeacb1c New version: 0.2.6. 2017-04-17 16:21:56 -07:00
Sergio Benitez
9b7f58448a New version: 0.2.5. 2017-04-16 14:29:04 -07:00
Sergio Benitez
f5ec470a7d Use the RawStr type for raw parameter strings.
This is a breaking change.

The `&str` type no longer implements `FromParam`. The `&RawStr` type
should be used in its place.
2017-03-31 00:18:58 -07:00
Sergio Benitez
0c44e44641 Use the RawStr type for all form raw strings.
This is a breaking change.

This commit introduces `RawStr` to forms. In particular, after this
commit, the `&str` type no longer implements `FromFormValue`, and so it
cannot be used as a field in forms. Instad, the `&RawStr` can be used.

The `FormItems` iterator now returns an `(&RawStr, &RawStr)` pair.
2017-03-30 23:06:53 -07:00
Sergio Benitez
f57d984e2e New version: 0.2.4. 2017-03-30 19:56:12 -07:00
Sergio Benitez
13359d4f50 Reformulate ContentType as a wrapper around MediaType. 2017-03-23 22:41:42 -07:00
Sergio Benitez
605e8fdc0e Update Tera to 0.8. 2017-03-23 15:28:49 -07:00
Sergio Benitez
09550b6e7c New version: 0.2.3. 2017-03-22 19:47:52 -07:00
Ryan Leckey
5086f0eb01 Default generic T in JSON to Value. 2017-03-08 17:53:05 -08:00
Sergio Benitez
fc89d0e96c Move {json,msgpack}/mod.rs to top-level contrib/src. 2017-03-08 15:17:37 -08:00
Josh Holmer
d43678c35e Add MsgPack implementation to contrib. 2017-03-08 15:12:00 -08:00
Sergio Benitez
6be902162d New version: 0.2.2. 2017-02-26 18:31:15 -08:00
Sergio Benitez
d99de8e05b New version: 0.2.1. 2017-02-24 13:57:33 -08:00
Sergio Benitez
46403b8d0a Iterate through Tera error chain for better errors. 2017-02-17 00:23:41 -08:00
Sergio Benitez
6184d94619 Expose docstring for JSON Responder impl. 2017-02-16 18:06:09 -08:00
Sergio Benitez
a496d1dbc4 Fix typos in JSON docs. 2017-02-09 00:18:47 -08:00
Sergio Benitez
c7db553286 New version: 0.2.0. 2017-02-06 05:35:19 -08:00
Sergio Benitez
266c62fb22 Implement FromFormValue for contrib UUID. 2017-02-03 17:09:22 -08:00
Sergio Benitez
aefa2f1494 Use pub(crate) to enforce doc(hidden). 2017-02-03 02:17:06 -08:00
Sergio Benitez
84abac7f2b Unignore template test. Upstream fix landed. 2017-02-02 18:48:34 -08:00
Sergio Benitez
2b65be32e0 Ignore render example due to broken upstream crate. 2017-02-02 15:39:30 -08:00
Sergio Benitez
5dff45086a Update to tera 0.7. 2017-02-02 15:18:23 -08:00
Sergio Benitez
ecc62beeac Update uuid in contrib to 0.4. 2017-02-02 14:51:04 -08:00
Sergio Benitez
cc22836867 Precisely route formats. Make 'content_type' an 'Option' in 'Request'.
This commit changes the routing algorithm. In particular, it enforces
precise matching of formats. With this change, a route with a specified
format only matches requests that have the same format specified. A
route with no format specified matches any request's format. This is
contrast to the previous behavior, where a route without a specified
format would match requests regardless of their format or whether one
was specified.

This commit also changes the following:
  * The return type of the 'content_type' method of 'Request' is now
    'Option<ContentType>'.
  * The 'ContentType' request guard forwards when the request has no
    specified ContentType.
  * The 'add_header' and 'replace_header' methods take the header
    argument generically.

Closes #120.
2017-02-01 03:12:24 -08:00
Sergio Benitez
5fabb43a1b Update to serde 0.9, handlebars 0.25. Move from map! to json! macro.
Resolves #154.
2017-01-31 17:15:42 -08:00
Sergio Benitez
5f04beaafc Use pegged Tera. 2017-01-28 21:52:36 -08:00
Sergio Benitez
8fd19cce4f Use upstream Tera. Emit warning on conflicting templates. 2017-01-26 12:47:20 -08:00
Sergio Benitez
c61e740572 Allow any Serialize type in RHS of map macro. 2017-01-26 11:56:06 -08:00
Sergio Benitez
0a0b64b9b6 New version: 0.1.6. 2017-01-26 11:26:50 -08:00
Sergio Benitez
b164da1a01 Rename JSON::unwrap() to JSON::into_inner(). 2017-01-15 03:00:46 -08:00
Sergio Benitez
08278e8f0e New version: 0.1.5. 2017-01-14 08:45:03 -08:00
Sergio Benitez
77ae330212 Minor style changes to UUID contrib. 2017-01-14 08:20:15 -08:00
Lori Holden
8f39d3399e Add UUID type to contrib. 2017-01-14 08:08:01 -08:00
Sergio Benitez
6fd0503cea Expose SerdeError. 2017-01-12 23:07:01 -08:00
Sergio Benitez
3c07cf96df Overhaul templating contrib library: use register callback.
This commit improves and changes the templating library in the following ways:

  * Templates are now registered/loaded at initialization.
  * No synchronization is required to read templates.
  * All templates are properly loaded (fixes #122).
  * Tera templates are given the proper name: `index`, not `index.html.tera`.
  * Rendering tests added for both templating engines.

There is one breaking change:

  * Tera templates are given the proper name: `index`, not `index.html.tera`.
2017-01-12 02:52:23 -08:00
Sergio Benitez
5db5e9f688 Update handlebars to 0.24. 2017-01-10 15:06:00 -08:00
Sergio Benitez
855d9b7b00 New version: 0.1.4. 2017-01-04 11:18:49 -06:00
Sergio Benitez
6fdc6f025f New version: 0.1.3. 2016-12-31 01:31:11 -06:00
Sergio Benitez
d610e0adff Update Tera dependency to 0.6. 2016-12-29 21:26:22 -06:00
Sergio Benitez
f43f77dbfc Improve Template docs and implement Display. 2016-12-29 13:20:30 -06:00
Marcus Ball
a33e225e71 Properly resolve nested template names on Windows. 2016-12-28 23:04:18 -06:00
Joel Roller
8deac6dba9 Add '.tera' extension to default Tera escapes. 2016-12-28 21:11:56 -06:00
Eric D. Reichert
13cac7db45 Fix URL to config guide in templates/mod.rs. 2016-12-26 19:05:06 -06:00
Sergio Benitez
fb7a756cf1 New version: 0.1.2. 2016-12-24 14:15:00 -08:00
Sergio Benitez
89f42a614d Properly resolve nested template names in contrib.
Fixes #42.
2016-12-24 14:03:56 -08:00
Sergio Benitez
14f79c3733 New version: 0.1.1. NamedFile hotfix. 2016-12-23 12:30:44 -08:00
Sergio Benitez
a94fcf41db New version: 0.1.0. First public release! 2016-12-23 05:03:07 -08:00