Commit Graph

48 Commits

Author SHA1 Message Date
Jeb Rosen
560f0977d3 Revamp testing system for async.
* body_string_wait and body_bytes_wait are removed; use `.await` instead
* `dispatch()` is now an async fn and must be .await-ed
* Add `#[rocket::async_test]` macro, similar in purpose to `tokio::test`
* Tests now use either `rocket::async_test(async { })` or
  `#[rocket::async_test]` in order to `.await` the futures returned
  from `dispatch()` and `body_{string,bytes}()`
* Update 'test.sh' to reflect the tests that should be passing.

Broken:

* Cloned dispatch and mut_dispatch() with a live previous response now both fail, due to a (partial) check for mutable aliasing in LocalRequest.
* Some tests are still failing and need example-specific changes.
2020-07-11 09:24:28 -07:00
Sergio Benitez
95c981de79 Test all guide code examples.
Every code example is now fully runnable and testable. As a result, all
examples are now tested and include imports. Relevant imports are shown
by default. Code examples can be expanded to show all imports.

Fixes #432.
2020-02-15 04:02:19 -08:00
Sergio Benitez
da7e022f99 Add Rust 2015 example. 2019-06-25 11:30:43 -07:00
Sergio Benitez
1bb23b8115 Rename 'space_helmet' to 'helmet'. Rework API. 2018-11-08 20:35:30 -08:00
Tal
c5167f1150 Add 'space_helmet' contrib module. 2018-11-08 20:35:26 -08:00
Sergio Benitez
9ef0b731c8 Rename 'codegen_next' to 'codegen'. 2018-10-22 00:01:41 -07:00
Sergio Benitez
360b0e80b0 Port all codegen tests to codegen_next. 2018-10-09 04:31:08 -07:00
jeb
8e779610c4 Reimplement 'routes!' and 'catchers!' as proc-macros. 2018-09-16 18:52:23 -07:00
Eric Dattore
60b9f06407 Implement connection pooling support in contrib.
Resolves #167.
2018-08-15 22:11:53 -07:00
Sergio Benitez
351b8f7c37 Small fixes to request-local state cache implementation. 2018-07-07 18:52:03 -07:00
Ville Hakulinen
97c6b3ace8 Implement Request-Local State Cache.
Resolves #654.
2018-07-07 18:41:21 -07:00
Sergio Benitez
df7111143e Split the 'http' module into its own 'rocket_http' crate. 2018-06-07 15:34:47 +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
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
5d4908e74a Update minimum nightly to '2018-01-12'.
The '2018-01-12' nightly release includes a commit that reverts the
change that broke 'ring', un-breaking 'ring', and thus un-breaking
Rocket. As a result, the '[patch]' workaround is no longer required.
Rocket is back on the latest nightly!
2018-01-12 19:44:21 -08:00
Sergio Benitez
b8367d52f8 Update codegen for 2017-12-22 nightly.
This works around #513 by patching 'ring' globally using the new
'[patch]' Cargo section.
2017-12-27 19:37:15 -08:00
lerina
7bda1b527b Added Tera templates example. 2017-11-17 12:07:53 -08: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
ac0c78a0cd Initial implementation of fairings: structured middleware for Rocket.
Closes #55.
2017-04-20 13:44:19 -07:00
Sergio Benitez
f2d054c4a2 Use upstream hyper. 2017-04-19 23:42:12 -07:00
Sergio Benitez
41386cfb78 Display the port that was resolved, not configured. 2017-04-19 02:51:44 -07:00
Stephan Buys
b4586f62ee Add managed_queue example and tests. 2017-04-14 14:54:14 -07:00
Sergio Benitez
e6203a77e7 Compile with 4 codegen units on dev. 2017-04-14 14:35:34 -07:00
Sergio Benitez
1516ca4fb6 Initial TLS support.
This commit introduces TLS support, provided by `rustls` and a fork of
`hyper-rustls`. TLS support is enabled via the `tls` feature and
activated when the `tls` configuration parameter is set. A new
`hello_tls` example illustrates its usage.

This commit also introduces more robust and complete configuration
settings via environment variables. In particular, quoted string,
array, and table (dictionaries) based configuration parameters can now
be set via environment variables.

Resolves #28.
2017-04-13 00:18:31 -07:00
Sergio Benitez
301257623c Update diesel and rusqlite example dependencies. 2017-03-30 02:02:09 -07:00
Josh Holmer
d43678c35e Add MsgPack implementation to contrib. 2017-03-08 15:12:00 -08:00
Sergio Benitez
16cb7297ab Initial session support.
This commit includes the following additions:
  * A `session` example was added.
  * `Config::take_session_key` was removed.
  * If a `session_key` is not supplied, one is automatically generated.
  * The `Session` type implements signed, encrypted sessions.
  * A `Session` can be retrieved via its request guard.
2017-03-08 03:28:12 -08:00
Sergio Benitez
7f9ced7db3 Add raw sqlite example; not in workspace due to sqlite3-sys conflict. 2017-02-02 18:00:30 -08:00
Lori Holden
f230d43fd5 Add example for the contrib UUID type. 2017-01-26 23:20:05 -08:00
Sergio Benitez
c815911705 Introduce Managed State. 2017-01-20 23:17:28 -08:00
Sergio Benitez
e0bc546e93 Add pastebin example. 2016-12-09 19:56:49 -08:00
Sergio Benitez
2f35b23514 Remove non-streaming requests. Use streaming requests everywhere.
This commit includes the following important API changes:

  * The `form` route parameter has been removed.
  * The `data` route parameter has been added.
  * Forms are not handled via the `data` parameter and `Form` type.
  * Removed the `data` parameter from `Request`.
  * Added `FromData` conversion trate and default implementation.
  * Added `DataOutcome` enum, which is the return type of `from_data`.
  * 'FromData' is now used to automatically derive the `data` parameter.
  * Moved `form` into `request` module.
  * Removed `Failure::new` in favor of direct value construction.

This commit includes the following important package additions:

  * Added a 'raw_upload' example.
  * `manual_routes` example uses `Data` parameter.
  * Now building and running tests with `--all-features` flag.
  * All exmaples have been updated to latest API.
  * Now using upstream Tera.

This commit includes the following important fixes:

  * Any valid ident is now allowed in single-parameter route parameters.
  * Lifetimes are now properly stripped in code generation.
  * `FromForm` derive now works on empty structs.
2016-10-12 00:14:42 -07:00
Sergio Benitez
d8db812856 Implement streaming requests. 2016-10-09 04:29:02 -07:00
Sergio Benitez
17b88d0a6b Implement configuration and environments. 2016-10-03 03:39:56 -07:00
Sergio Benitez
6fe2f51332 Add form kitchen sink example. 2016-09-28 19:31:26 -07:00
Sergio Benitez
23808d00bc This commit squash three form-related commits:
Remove form_items function in favor of FormItems iterator.

  Add specialized `bool` implementation of FromFormValue.

  Add `&str` implementation of FromFormValue for debugging.
2016-09-28 19:29:18 -07:00
Sergio Benitez
31cca896f4 Use upstream Aster now that PR has been merged. 2016-09-24 17:54:34 -07:00
Sergio Benitez
f74e286e31 Add templating support in contrib crate.
The contrib crate now contains support for both Handlebars and Tera. No
documentation yet.

resolves #5
2016-09-22 04:12:07 -07:00
Sergio Benitez
a3218192dd Add contrib crate. Add JSON to contrib. Add JSON example. 2016-09-19 16:24:01 -07:00
Sergio Benitez
8824d498d1 Add streaming responder and example. 2016-09-12 02:43:34 -07:00
Sergio Benitez
327b28a98e Add query params to Rocket. Use Ident for attribute params. 2016-09-04 19:18:08 -07:00
Sergio Benitez
fec443a3f0 Fix issue #1. 2016-09-04 13:51:16 -07:00
Sergio Benitez
99074a913d Add example for future testing API. 2016-08-27 16:20:01 -07:00
Sergio Benitez
a34374d913 Output all matching routes, not just first ranked. 2016-08-26 21:34:28 -07:00
Sergio Benitez
bd9d553050 New type: ContentType. Parse ContentType from attribute. 2016-08-22 20:34:22 -07:00
Sergio Benitez
025c9243c0 Now using a Cargo workspace for (much!) faster builds. Added a temporary query
params example.
2016-08-10 17:50:08 -07:00
Sergio Benitez
2e2cc3c216 Rocket is almost operational! routes! macro complete.
Here's what works so far:

  * The `route` decorator checks its inputs correctly. There's a nice utility
    for doing this, and it's working quite well at the moment.

  * The `route` decorator emits a `route_fn` and a `route_struct`. The `routes`

  * macro prepends the path terminator with the route struct prefix. The

  * `Rocket` library can read mount information (though not act on it properly
    just yet) and launch a server using Hyper.
2016-03-12 10:45:19 -08:00
Sergio Benitez
967fcd26b2 Initial commit. Checking for method and path arguments in route. Not storing the info anywhere yet. 2016-03-07 11:28:04 -08:00