Commit Graph

237 Commits

Author SHA1 Message Date
Sergio Benitez 9f9971f4cf Tidy up handlebars example. 2017-12-28 20:52:03 -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 bbad1a11ec Use 'into()' in handlebars templates tests. 2017-11-17 12:25:33 -08:00
Sergio Benitez 0d2585051d Fixup Tera templates example for master. 2017-11-17 12:23:51 -08:00
lerina 7bda1b527b Added Tera templates example. 2017-11-17 12:07:53 -08:00
Sergio Benitez 07d4d23cc8 Update dependencies. 2017-10-09 20:15:18 -07:00
Sergio Benitez 237c673be4 Rename '#[error]' to '#[catch]', 'errors!' to 'catchers!'. 2017-09-22 19:04:14 -07:00
Sergio Benitez 32eeae1733 Use 'Uri' instead of 'String' in 'Redirect'. 2017-09-15 04:00:50 -07:00
Sergio Benitez 084481a84e Initial implementation of typed URIs.
This is a breaking change. All Rocket applications using code
generation must now additionally declare usage of the 'decl_macro'
feature.
2017-09-14 22:10:25 -07:00
Lucas Kolstad 2d72928ba1 Properly handle paths with spaces in shell scripts. 2017-09-07 17:07:31 -07:00
Sergio Benitez 237370533c Update cert in 'tls' example for new 'rustls'.
The latest version of `rustls` acts on the SNI extension to TLS without
the apparent ability to disable the behavior. `rustls` requires that the
server's certificate match the client's requested server. The matching
is done by looking at DNS names in the `subjectAltName` extension and
checking if the requested server name is present. Since the certificate
in the `tls` example did not have the `subjectAltName` extension, this
check always failed, and the TLS connection was aborted. This commit
adds the extension to the certificate with a DNS name of `localhost`,
ensuring that TLS succeeds on `localhost`.
2017-09-01 03:16:36 -07:00
Sergio Benitez 3ed0201c6e Remove unused 'extern crate's. 2017-08-31 17:03:47 -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 8183f63630 Remove lints and associated code from 'rocket_codegen'.
Rust's linting API is incredibly unstable, resulting in unnecessary
breakage to `rocket_codegen`. Rocket's lints are also not as
conservative as would be desired, resulting in spurious warnings. For
these reasons, this commit removes linting from `rocket_codegen`.

These lints will likely be reintroduced as part of a 'rocket_lints'
crate. Factoring the lints out to a separate crate means that lint
breakage can be dealt with by uncommenting the dependency instead of
waiting for a new release or backtracking nightlies. In the same vein,
it will likely improve stability of the 'rocket_codegen' crate.
2017-08-15 11:39:22 -07:00
Rolf Sievers 3a76fe03db Improve commentary on collisions in pastebin example. 2017-08-13 02:56:23 -07:00
Katrina Brock 527051d136 Improve bootstrapping instructions in todo example. 2017-08-13 02:50:28 -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 05944c01af Update diesel example dependency to 0.14. 2017-07-06 02:04:00 -07:00
Sergio Benitez 05a8a93eec Add tests for the 'session' example.
Closes #316.
2017-07-04 14:51:41 -07:00
Sergio Benitez 8eb1fff93f Silence incorrect unmanaged state warnings. 2017-07-03 15:37:24 -07:00
Sergio Benitez 150aef7764 Impl 'try' for 'Outcome'. Document 'Cookies'.
The 'try' impl for 'Outcome' allows the '?' operator to be used with
'Outcome' values. This is likely to make 'FromRequest' and 'FromData'
implementations more ergonomic.

This commit also expands the 'IntoOutcome' trait. It is now
implemented for 'Option'. It also now includes an additional
'or_forward' method.
2017-06-24 02:49:31 -07:00
Sergio Benitez cdf9ff9bde Remove 'LoggingLevel' from root. Add ConfigError::Io.
This tentatively completes the 'config' rustdocs.
2017-06-18 21:06:41 -07:00
Sergio Benitez ea485e52e8 Update diesel and rusqlite example dependencies. 2017-06-11 02:57:41 -07:00
Sergio Benitez b8ba7b855f Remove Session in favor of private cookies. New testing API.
Sessions
--------

This commit removes the `Session` type in favor of methods on the
`Cookies` types that allow for adding, removing, and getting private
(signed and encrypted) cookies. These methods provide a superset of
the functionality of `Session` while also being a minimal addition to
the existing API. They can be used to implement the previous `Session`
type as well as other forms of session storage. The new methods are:

  * Cookie::add_private(&mut self, Cookie)
  * Cookie::remove_private(&mut self, Cookie)
  * Cookie::get_private(&self, &str)

Resolves #20

Testing
-------

This commit removes the `rocket::testing` module. It adds the
`rocket::local` module which provides a `Client` type for local
dispatching of requests against a `Rocket` instance. This `local`
package subsumes the previous `testing` package.

Rocket Examples
---------------

The `forms`, `optional_result`, and `hello_alt_methods` examples have
been removed. The following example have been renamed:

  * extended_validation -> form_validation
  * hello_ranks -> ranking
  * from_request -> request_guard
  * hello_tls -> tls

Other Changes
-------------

This commit also includes the following smaller changes:

  * Config::{development, staging, production} constructors have been
    added for easier creation of default `Config` structures.
  * The `Config` type is exported from the root.
  * `Request` implements `Clone` and `Debug`.
  * `Request::new` is no longer exported.
  * A `Response::body_bytes` method was added to easily retrieve a
    response's body as a `Vec<u8>`.
2017-06-08 17:34:50 -07:00
Sergio Benitez 3eeae77ed6 Add tests for 'form_kitchen_sink' example.
Closes #62.
2017-06-02 18:46:34 -07:00
Sergio Benitez 6f4c8b1377 Don't create two DB pools in todo example. 2017-06-01 23:03:08 -07:00
Sergio Benitez f1ec552ac5 Make todo example bootstrapping more resilient. 2017-06-01 22:10:05 -07:00
Sergio Benitez 6a9421935e Add 'Request::route' method to get active 'Route'.
This commit also adds the `base` field to `Route` which allows the
base mount point to be retrieved. Finally, this commits adds an
implementation of `FromRequest` for `Route` which returns the active
route if one is available or forwards otherwise.

This commit is a breaking change: it makes `Request` and `MockRequest`
invariant over the lifetime `'r`. While this shouldn't affect most
applications, it may affect some.

Resolves #108.
2017-05-29 18:00:33 -07:00
Sergio Benitez 83002d3203 Don't assume there is an existing DB. 2017-05-26 17:12:57 -07:00
Sergio Benitez 614ec1359e Add tests for 'todo' example. 2017-05-26 16:52:17 -07:00
Sergio Benitez 6a7903a220 Add tests for 'raw_upload' example. 2017-05-24 22:56:57 -07:00
Sergio Benitez 732cb26eb5 Add tests for 'stream' example. 2017-05-24 22:45:03 -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
Sergio Benitez 28a1ef0916 Fairings, v3.
Modifying the `Rocket` structure just before launch doesn't make sense for
several reasons: 1) those affects can't influence the launch, and 2) they won't
be observed in tests. Thus, an `Attach` fairing kind was added that ameliorates
these issues.
2017-05-17 01:39:36 -07:00
Sergio Benitez 9c9740f966 Fairings v2. 2017-05-14 21:46:01 -07:00
Anton Pirker 781477fff1 Rename 'session_key' config parameter to 'secret_key'.
Resolves #220.
2017-05-12 17:24:25 -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 1e5a1b8940 Remove 'testing' feature. Close stream on network error.
This is a breaking change.

The `testing` feature no longer exists. Testing structures can now be
accessed without any features enabled.

Prior to this change, Rocket would panic when draining from a network
stream failed. With this change, Rocket force closes the stream on any
error.

This change also ensures that the `Fairings` launch output only prints
if at least one fairing has been attached.
2017-04-20 20:36:12 -07:00
Sergio Benitez ac0c78a0cd Initial implementation of fairings: structured middleware for Rocket.
Closes #55.
2017-04-20 13:44:19 -07:00
Sergio Benitez d6e86be1b0 Make route collisions a hard error.
This is a breaking change. Previously, route collisions were warnings.
2017-04-18 17:42:44 -07:00
Sergio Benitez f97b02dda6 Note the extras in the config example. 2017-04-18 17:32:32 -07:00
Sergio Benitez 6dc21e5380 Add support for configurable size limits. 2017-04-18 00:25:13 -07:00
Sergio Benitez 7d2a114280 Set version of managed_queue example to 0.0.0. 2017-04-14 14:58:17 -07:00
Sergio Benitez 8d14cd571c Tidy up managed_queue example. 2017-04-14 14:54:19 -07:00
Stephan Buys b4586f62ee Add managed_queue example and tests. 2017-04-14 14:54:14 -07:00
Sergio Benitez e6615af7e6 Add tests for pastebin example. 2017-04-14 14:39:17 -07:00
Sergio Benitez 3bebdcc53d Add Response::body_string(). Use it in all tests. 2017-04-14 01:59:28 -07:00