Commit Graph

254 Commits

Author SHA1 Message Date
Sergio Benitez
d17b392538 Use diesel <= 1.2 while nightly issues persist. 2018-05-29 18:37:14 +02:00
Kyle Clemens
105137a46d Rename 'UUID' to 'Uuid' in 'rocket_contrib'. 2018-04-14 20:07:50 -07:00
Sergio Benitez
9629b40202 Clear flash cookies only after they're inspected.
Resolves #512.
Resolves #466.
2018-04-14 19:53:36 -07:00
Sergio Benitez
efc511c6dc Add a 'FromFormValue' derive. Start 'codegen_next' crate.
The 'codegen_next' crate will eventually be renamed 'codegen'. It
contains procedural macros written with the upcoming 'proc_macro' APIs,
which will eventually be stabilized. All compiler extensions in the
present 'codegen' crate will be rewritten as procedural macros and moved
to the 'codegen_next' crate.

At present, macros from 'codegen_next' are exported from the core
`rocket` crate automatically. In the future, we may wish to feature-gate
this export to allow using Rocket's core without codegen.

Resolves #16.
2018-04-12 16:07:37 -07:00
Sergio Benitez
5b4a35d508 Update codegen for 2018-04-06 nightly. 2018-04-07 13:51:57 -07:00
Sergio Benitez
362f0ccdac Allow shorthand for route format specifiers. 2018-03-22 04:02:37 -05:00
Sergio Benitez
794dc66e3b Remove unnecessary 'dotenv' dependency in 'todo' example. 2018-02-25 20:20:06 -08:00
Sergio Benitez
d4e590af83 Fix 'diesel' version in state guide and todo example. 2018-02-21 16:07:09 -08:00
Eric Dattore
c48905f483 Use 'diesel::r2d2' in state guide and todo example.
Diesel now reexports r2d2, so rather than including that library
explicitly, let's leverage the reexport.
2018-02-21 15:53:02 -08:00
Sergio Benitez
b76a1ef8b9 Update 'uuid' dependency to '0.6'.
Resolves #565.
2018-02-21 00:57:39 -08:00
Sergio Benitez
c620411d92 Add 'keep_alive' configuration parameter.
The 'keep_alive' configuration parameter allows HTTP keep-alive timeouts
to be configured or for keep-alive to be disabled entirely.
2018-02-17 04:06:05 -08:00
Sergio Benitez
de8e1978c5 Remove unsafe 'from_utf8_unchecked'; improve form parsing.
The 'FormItems' iterator now successfully parses empty keys and values
as well as keys without values.
2018-02-14 14:05:26 -08:00
Donald Robertson
19f59b1f9b Use port 8000 as default for all environments.
Closes #317.
2018-01-20 09:43:19 -08:00
Sergio Benitez
f04dc195bd Update 'rusqlite' to fix dependency resolution. 2018-01-19 10:29:51 -08:00
Sergio Benitez
65baa83fb4 Update dependencies.
* 'memchr' to 2.0
  * 'base64' to 0.9
  * 'smallvec' to 0.6
  * 'lazy_static' to 1.0

Update example dependencies.

  * 'rand' to 0.4
  * 'parking_lot' to 0.5
2018-01-05 02:00:26 -08:00
Sergio Benitez
24b2818f8c Update diesel to 1.0. 2018-01-03 01:38:11 -08:00
calhilcaw
401bedebb2 Update docs and examples for diesel 1.0.0-rc1. 2018-01-03 01:38:05 -08:00
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