Commit Graph

677 Commits

Author SHA1 Message Date
Sergio Benitez ce363810c5 Disable coloring when output isn't a tty. 2017-06-19 18:29:26 -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 cdf9ff9bde Remove 'LoggingLevel' from root. Add ConfigError::Io.
This tentatively completes the 'config' rustdocs.
2017-06-18 21:06:41 -07:00
Sergio Benitez 43a4028085 Use a less confusing version number during dev. 2017-06-18 02:25:26 -07:00
Vesa Kaihlavirta 3ef14f5392 Fix benchmarks to use 'route.uri' instead of 'route.path'. 2017-06-18 02:07:13 -07:00
Sergio Benitez a3ea9d0f9a Add support for lenient forms via 'LenientForm'.
This commit changes the 'FromForm' trait in two ways:

  1. The singular method is now named 'from_form'.
  2. The method takes a second parameter: 'strict: bool'.

The 'strict' parameter is used to specify whether form parsing should
be strict or not (i.e. lenient). When parsing is lenient, extra form
fields do not result in an error. This lenient behavior is used by a
new 'LenientForm' data guard type to request lenient form parsing. The
behavior for 'Form' remains unchanged.

Resolves #242.
2017-06-18 01:59:22 -07:00
Sergio Benitez 8536e39d10 Update 'cookie' for cookie path deletion fix. 2017-06-17 13:31:24 -07:00
Sergio Benitez 876a8b8329 Make tera/handlebars rendering a little clearer. 2017-06-16 20:56:51 -07:00
Sergio Benitez 2aad1d876b Update ring-based dependencies. 2017-06-16 20:32:20 -07:00
Sergio Benitez 3fcf6c43dc Clean up LaunchError docs. Add Rocket::{config, routes} example.
This commit also:

  * Cleans up the stored URIs in routes.
  * Removes LaunchError as a root export.
  * Adds a URI::base() method.
2017-06-12 15:11:01 -07:00
Sergio Benitez 7cf3367183 Document the `Limits` structure. Change default workers.
The default workers config parameter is now [num_cpus * 2].
2017-06-11 03:39:30 -07:00
Sergio Benitez ea485e52e8 Update diesel and rusqlite example dependencies. 2017-06-11 02:57:41 -07:00
Sergio Benitez 8badc73c4b Update toml to 0.4. Add Config::get_datetime. 2017-06-11 02:20:57 -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 f57d5146d3 Fix link to COMPILER_TESTS in README. 2017-06-09 03:04:41 -07:00
Sergio Benitez d09920c021 Emit warning when no 'secret_key' is set in prod. 2017-06-08 23:33:16 -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 504a7fe583 Update to yansi 0.3 for proper Debug formatting.
This commit also improves the format of TOML parsing error messages.

Fixes #310.
2017-06-06 13:56:13 -07:00
Sergio Benitez 3eeae77ed6 Add tests for 'form_kitchen_sink' example.
Closes #62.
2017-06-02 18:46:34 -07:00
Sergio Benitez fa31b6ae42 Support the 'dev' channel during build.
Resolves #306.
2017-06-02 17:41:15 -07:00
Sergio Benitez 6f4c8b1377 Don't create two DB pools in todo example. 2017-06-01 23:03:08 -07:00
Sergio Benitez a6c4d053ad Switch to 'yansi' for all terminal coloring.
Resolves #299.
2017-06-01 22:10:05 -07:00
Sergio Benitez 73fed03ef4 New version: 0.2.8. 2017-06-01 22:10:05 -07:00
Sergio Benitez 614297eb9b Update codegen lints for latest nightly. 2017-06-01 22:10:05 -07:00
Sergio Benitez f1ec552ac5 Make todo example bootstrapping more resilient. 2017-06-01 22:10:05 -07:00
Sergio Benitez e42fe78e41 Update 'smallvec' dependency to 0.4. 2017-05-31 17:28:12 -07:00
Sergio Benitez 923b84f42c Remove outdated comment FIXME. 2017-05-29 18:10:07 -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 a4292ba666 Update site for 0.2.7. 2017-05-26 20:38:56 -07:00
Sergio Benitez 5f2b2ee3df New version: 0.2.7. 2017-05-26 20:37:54 -07:00
Sergio Benitez cdc866665c Update codegen for latest nightly. 2017-05-26 20:37:40 -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 3c64898840 Clarify relation between Responders and error catchers.
Thanks to @echochamber for the initial push.

Closes #271.
2017-05-24 16:50:05 -07:00
Sergio Benitez 6a5d8ab58a Update rustls and hyper-rustls dependencies. 2017-05-24 16:02:16 -07:00
Sergio Benitez 299a422cbc Optimize MediaType::Display, ContentType::Into<Header>, and precheck.
Differential and causal profiling determined that 35% of `Hello, world!`
dispatch time was spent rendering `Content-Type` due to many calls to `fmt` in
`MediaType::Display` and an allocation in `ContentType::Into<Header>`. This
change reduces the number of calls to `fmt` to 1 in `MediaType::Display` and
removes the allocation in `Into<Header>` for known media types.

This change also caches a `Rocket` "precheck" so that pre-dispatch checks are
done only a single time for a given `Rocket` instance, further reducing
`MockRequest::dispatch_with` time for "Hello, world!" by roughly 15%.
2017-05-23 16:41:38 -07:00
Sergio Benitez d93d366ce7 Remove use of type_ascription feature. 2017-05-20 11:51:17 -07:00
Sergio Benitez 6c00d362c0 Add ResponseBuilder::raw_body. Use OrderMap for HeaderMap. 2017-05-20 11:41:44 -07:00
Sergio Benitez 80a1abdc89 Add hello_world benchmark. 2017-05-19 19:39:10 -07:00
Sergio Benitez 42c98fe1c3 Rename 'extra' Request field to 'state'. 2017-05-19 19:38:56 -07:00
Sergio Benitez fc7d51d010 Check before dumping data in kill_stream. 2017-05-19 19:38:28 -07:00
Sergio Benitez 4cab891fda Default session removal cookie path to '/'.
Fixes #295.
2017-05-19 03:46:19 -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
Sergio Benitez 9a7484f7a8 Reclose connection on unread data. Minimum nightly is 1.19. 2017-05-13 02:00:35 -07:00