Jeb Rosen
4bb4c61528
Allow implementations of on_request fairings to return a Future that borrows from self, request, and data.
2020-07-11 09:24:29 -07:00
Jeb Rosen
cc3298c3e4
Allow implementations of FromData to return a Future that borrows from the request.
2020-07-11 09:24:29 -07:00
Jeb Rosen
468f4d9314
Simplify FromRequestAsync trait definition.
2020-07-11 09:24:29 -07:00
Paolo Barbolini
003bf77c29
Upgrade to tokio 0.2.0.
...
* Update 'tokio', 'tokio-rustls', and 'hyper'.
* Remove unused dependencies on some `futures-*` crates.
* Rework 'spawn_on', which is now 'serve'.
* Simplify Ctrl-C handling.
2020-07-11 09:24:29 -07:00
Jeb Rosen
7c4cd068d1
Update for rust-lang/rust#64856 .
...
Raise the nightly version to one that accepts '...(format!(...)).await'.
This additionally reverts commit bdbf80f2da
.
2020-07-11 09:24:29 -07:00
Jeb Rosen
6321797a74
Update compile error tests for databases.
2020-07-11 09:24:29 -07:00
Jeb Rosen
df52616074
Update error positions after changes for async #[catch] support.
2020-07-11 09:24:29 -07:00
Jeb Rosen
2fa2d636e4
Implement FromRequestAsync instead of FromRequest for Option and Result.
2020-07-11 09:24:29 -07:00
Jeb Rosen
4e5b889358
Add async-routes test for #[get] and #[catch].
2020-07-11 09:24:29 -07:00
Follpvosten
189fd65b17
Add 'Request::local_cache_async' for use in async request guards.
2020-07-11 09:24:29 -07:00
Jeb Rosen
5317664893
Fix UI tests for FromRequestAsync.
2020-07-11 09:24:29 -07:00
Jeb Rosen
1c28a9413b
Allow catchers to be async fn.
2020-07-11 09:24:29 -07:00
Jeb Rosen
0ab787e216
Use 'tokio_executor::blocking' when acquiring connections from synchronous database pools to avoid tying up the executor.
2020-07-11 09:24:29 -07:00
Jeb Rosen
adf7e4233a
Add 'FromRequestAsync' and use it in route codegen.
...
'FromRequestAsync' is automatically implemented for all types
that implement 'FromRequest'.
2020-07-11 09:24:29 -07:00
Jeb Rosen
ea06878581
Update 'hyper', 'futures-*-preview', and 'tokio-*' dependencies.
...
Use I/O traits and types from 'tokio-io' as much as possible.
A few adapters only exist in futures-io-preview and use
futures-tokio-compat as a bridge for now.
2020-07-11 09:24:29 -07:00
Jeb Rosen
0d89637e8b
Propagate errors while writing out response instead of panicking.
2020-07-11 09:24:28 -07:00
Jeb Rosen
8718561bf8
Emit an error when #[async_test] is applied to a function with parameters.
2020-07-11 09:24:28 -07:00
Jeb Rosen
76ef92a2e1
Use a tokio timer instead of std: 🧵 :sleep in template reload test.
2020-07-11 09:24:28 -07:00
Jeb Rosen
d1815e527f
Update 'hyper', 'tokio', and 'tokio-rustls'.
...
* hyper -> 0.13.0-alpha.2
* tokio -> 0.2.0-alpha.5
* tokio-rustls -> 0.12.0-alpha.3
2020-07-11 09:24:28 -07:00
Jeb Rosen
af36f299c6
Fix ordering of messages in a UI test.
2020-07-11 09:24:28 -07:00
Jeb Rosen
523c6099fb
Replace use of 'hyper::AddrIncoming' with a Listener API and implement TLS.
...
Types can now implement the new 'Listener' trait, which means they can
report the address they are listening on and asynchronously accept
connections. 'Connection's are read/write streams that can additionally
report the remote address.
Listener is implemented for 'tokio_net::tcp::TcpListener' and for
the new 'rocket_http::tls::TlsListener' based on 'tokio-rustls'.
The new private function 'Rocket::listen_on()' now does the main setup
for launch and is generic over a Listener. In the future, a more refined
version of the API can be exposed so that applications can implement
their own listeners.
2020-07-11 09:24:28 -07:00
Jeb Rosen
62a99e9e49
Fix a minor compilation error, possibly caused by rust-lang/rust#64292 .
2020-07-11 09:24:28 -07:00
Jeb Rosen
77a64c73bb
Fix some launch error handling in tests and examples.
2020-07-11 09:24:28 -07:00
Jeb Rosen
a0d2651e38
Fix a few unused import warnings.
2020-07-11 09:24:28 -07:00
Jacob Pratt
cd6a80c230
Implement an API to request a graceful shutdown.
...
Additionally listen for Ctrl-C as a shutdown signal by default.
2020-07-11 09:24:28 -07:00
Jeb Rosen
0d6e46944b
Use tokio's current_thread runtime for async_test to increase performance.
2020-07-11 09:24:28 -07:00
Jacob Pratt
c7ecfc69c3
Use 'futures::future::BoxFuture' instead of 'Pin<Box<...>>' for readability.
2020-07-11 09:24:28 -07:00
Jacob Pratt
bd929ef617
Remove unnecessary boxing of some Futures.
2020-07-11 09:24:28 -07:00
Jacob Pratt
1f90a9b6d1
Update hyper to '=0.13.0-alpha.1'.
2020-07-11 09:24:28 -07:00
Jeb Rosen
baa2ed27f3
Update UI tests affected by removal of typed headers.
2020-07-11 09:24:28 -07:00
Jeb Rosen
facc00454c
Re-enable the entire test suite:
...
* Disable compression tests
* Finish migrating all other examples and tests
2020-07-11 09:24:28 -07:00
Jeb Rosen
047b1620f9
Update pinned hyper and tokio versions.
2020-07-11 09:24:28 -07:00
Jacob Pratt
05426881b0
Use 'File' from 'async_std' instead of from 'tokio'.
...
Additionally pin tokio to '=0.2.0-alpha.2'; before this change cargo
selects '0.2.0-alpha.3' which hyper does not compile against.
2020-07-11 09:24:28 -07:00
Jeb Rosen
1f0577bfc5
Update remaining examples for async.
2020-07-11 09:24:28 -07:00
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
Jacob Pratt
a87e1577aa
Add 'Rocket::spawn_on' to spawn a server on a user-provided (tokio) runtime.
2020-07-11 09:24:28 -07:00
Jacob Pratt
e44c5896b8
Remove stabilized 'async_await' feature gate and update the minimum nightly version.
2020-07-11 09:24:28 -07:00
Jeb Rosen
af95129590
Use futures 0.3-compatible hyper and tokio and the tokio runtime instead
...
of futures-rs executor.
Despite this change, using body_bytes_wait on (for example) a File will
still fail due to tokio-rs/tokio#1356 .
2020-07-11 09:24:28 -07:00
Jeb Rosen
8c8598b4fd
Fix 'static_files' and 'serve' tests.
2020-07-11 09:24:28 -07:00
Jeb Rosen
b780f9d8e0
Fix or ignore remaining doc tests in 'core'.
...
This adds an unstable "async_test" function for use in tests, to ensure
they stay working while refactoring other APIs.
2020-07-11 09:24:28 -07:00
Jeb Rosen
aee7f35095
Use read_to_string (from futures-preview 0.3.0-alpha.18) to more closely match the pre-async code.
2020-07-11 09:24:28 -07:00
Jacob Pratt
0e6841da66
Convert two internal functions returning `Pin<Box<_>>` to `async fn`.
2020-07-11 09:24:28 -07:00
Jeb Rosen
b56e889a0e
Disable some known-failing tests for now.
2020-07-11 09:24:28 -07:00
Jeb Rosen
633e495a6b
Update many doc tests in 'core' for async.
2020-07-11 09:24:28 -07:00
Jeb Rosen
1601e5c814
Fix a few 'unused use' warnings.
2020-07-11 09:24:28 -07:00
Jeb Rosen
094146b929
Update 'fairings' example for async.
2020-07-11 09:24:28 -07:00
Jeb Rosen
bc404f1f6d
Use 'body_string_wait' in all example tests.
2020-07-11 09:24:28 -07:00
Redrield
5e578e9c3b
Upgrade 'msgpack' for async in contrib and examples.
2020-07-11 09:24:28 -07:00
Jeb Rosen
6044961680
Update parts of contrib and associated tests and examples:
...
* json
* templates
* helmet
* databases
* serve
* examples/cookies
* examples/handlebars_templates
* examples/json
* examples/session
* examples/static_files
* examples/tera_templates
2020-07-11 09:24:28 -07:00
Jeb Rosen
7c34a3a93e
Make 'Fairing::on_response' and 'Responder::respond_to' async.
...
This is required to be able to do anything useful with the body in the
outgoing response. Request fairings do not appear to need to be async
as everything on Data that returns a future moves self and on_request only
gets &Data, but the same change in this commit should work for on_request
if desired.
2020-07-11 09:24:28 -07:00