Commit Graph

108 Commits

Author SHA1 Message Date
Sergio Benitez
f1c7d3e27c Minor code improvements via clippy. 2016-12-17 09:18:30 -08:00
Sergio Benitez
6815a56cb5 Rework Request: add lifetime to future proof, remove unsafe. 2016-12-16 03:07:23 -08:00
Sergio Benitez
368e5105a9 Return a Response from testing's dispatch_with. 2016-12-15 20:53:54 -08:00
Sergio Benitez
08f41816d1 Remove dependence from Hyper in Request/MockRequest. 2016-12-15 16:34:19 -08:00
Sergio Benitez
44f5f1998d New HTTP types: ContentType, Status. Responder/Handler/ErrorHandler changed.
This is a complete rework of `Responder`s and of the http backend in
general. This gets Rocket one step closer to HTTP library independence,
enabling many future features such as transparent async I/O, automatic
HEAD request parsing, pre/post hooks, and more.

Summary of changes:

  * `Responder::response` no longer takes in `FreshHyperResponse`.
    Instead, it returns a new `Response` type.
  * The new `Response` type now encapsulates a full HTTP response. As a
    result, `Responder`s now return it.
  * The `Handler` type now returns an `Outcome` directly.
  * The `ErrorHandler` returns a `Result`. It can no longer forward,
    which made no sense previously.
  * `Stream` accepts a chunked size parameter.
  * `StatusCode` removed in favor of new `Status` type.
  * `ContentType` significantly modified.
  * New, lightweight `Header` type that plays nicely with `Response`.
2016-12-15 00:47:31 -08:00
Sergio Benitez
b72af317f1 Simplify pastebin retrieve handler. 2016-12-09 21:01:30 -08:00
Sergio Benitez
0be423a35e Updated dependency versions. 2016-12-09 20:14:49 -08:00
Sergio Benitez
e0bc546e93 Add pastebin example. 2016-12-09 19:56:49 -08:00
Sergio Benitez
0ce41c0f2c Remove stale comments. 2016-11-13 18:54:49 -08:00
Sergio Benitez
2cc0251a22 Further document the Catcher type. Register a catcher in the manual example. 2016-11-05 19:31:50 +01:00
Sergio Benitez
d843e8354c Use handlebars so that message is escaped in cookies example. 2016-11-04 15:33:58 +01:00
Sergio Benitez
5b8b41bcd8 Fix examples for updates Redirect API. 2016-11-03 19:09:08 +01:00
Sergio Benitez
2fec4209c9 Use FlashMessage in todo example. 2016-11-02 18:49:06 +01:00
Sergio Benitez
d24d5534f4 Return a 404 when a file isn't found. 2016-11-02 17:47:00 +01:00
Sergio Benitez
c98d047038 Add URI::percent_decoding helper method. Safeguard Pathbuf FromSegments implementation. 2016-11-02 16:55:56 +01:00
Sergio Benitez
d91e3e0454 Add the [global] psuedo-environment for global configuration. 2016-10-31 17:00:32 +01:00
Sergio Benitez
da7cb44671 Add more testing module documentation. Fix test for latest nightly. 2016-10-31 10:21:19 +01:00
Sergio Benitez
6a8d64f69b Move the data module into the top-level namespace. 2016-10-25 13:24:07 +02:00
Sergio Benitez
f5a5ea3a22 Rename data to content in response. Remove DataOutcome. 2016-10-25 13:03:50 +02:00
Sergio Benitez
5447f81f77 Remove RequestOutcome, ResponseOutcome in favor of Outcome. Remove Failure response type. 2016-10-25 11:17:49 +02:00
Sergio Benitez
a145a11848 Add tests to the hello_world, helllo_ranks, and hello_person examples. 2016-10-17 15:14:57 -07:00
Sergio Benitez
bc5ecb31df Implement a small testing framework in the 'testing' module. 2016-10-16 03:16:16 -07:00
Sergio Benitez
1323e7a420 Add config::get(), for global config access. Use it for Template. 2016-10-14 18:57:36 -07:00
Sergio Benitez
722f613686 Use Outcome as the result of all fallible conversions. 2016-10-13 18:39:23 -07:00
Sergio Benitez
b4305cb430 Use 'Content-Type' for format routing. Simplify 'raw_upload' example. 2016-10-12 19:08:19 -07:00
Sergio Benitez
4769b17d13 Use 'format' in 'raw_upload' example instead of checking Content-Type directly. 2016-10-12 16:48:32 -07:00
Sergio Benitez
a9b12568d9 Update to upstream diesel. 2016-10-12 00:38:30 -07: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
216b30cb78 Remove accidentally included file. 2016-10-08 21:06:53 -07:00
Sergio Benitez
7c6dce266b Update cookies example to use contrib Template. 2016-10-08 21:02:42 -07:00
Sergio Benitez
619b1d787e Rename Response::new to complete. Add Response::failure using newly added Failure response. 2016-10-08 20:53:04 -07:00
Sergio Benitez
6275e576b5 Updates for latest nightly. Use Tera from main branch. 2016-10-08 19:27:33 -07:00
Sergio Benitez
8c0d11feab Completely new raw API.
Summary of changes:

  * Request no longer has a lifetime parameter.
  * Handler type now includes a `Data` parameter.
  * Response is now an enum that is either `Complete` or `Forward`.
  * Outcome enum is now one of: Success, Failure, Forward.
  * Outcome::Foward for Responses must include StatusCode.
  * Responders are now final: they cannot forward to requests. (!!)
  * Responsers may only forward to catchers. (!!)
  * Response no longer provides wrapping methods.
  * Route is now cloneable.

This change is fundamental to enabling streaming requests.
2016-10-07 23:20:49 -07:00
Sergio Benitez
37e6a367b8 Move the form module under request and outcome to top-level. 2016-10-07 19:27:50 -07:00
Sergio Benitez
bcb9bd860b Allow different lifetimes in handler Request reference and its contents. 2016-10-06 20:38:13 -07:00
Sergio Benitez
650d079b58 Make the uri parameter in Request private. 2016-10-06 00:08:00 -07:00
Sergio Benitez
d4f9525b22 Allow error handlers to take 0, 1, or 2 parameters.
fixes #13
2016-10-04 15:05:25 -07:00
Sergio Benitez
4b6c72e33f Use move builder pattern to launch Rocket apps. 2016-10-03 19:48:33 -07:00
Sergio Benitez
7b1dc5a1a4 Remove Rocket::new(). Use 'ignite' everywhere. 2016-10-03 19:37:49 -07:00
Sergio Benitez
d631dfd300 Use ignite in README example. Check ROCKET_ENV without Rocket.toml being present. 2016-10-03 19:21:21 -07:00
Sergio Benitez
920bd35d46 Update serde in examples. 2016-10-03 17:56:43 -07:00
Sergio Benitez
74ec26db95 Namespace HTTP-related type under http. 2016-10-03 17:09:13 -07:00
Sergio Benitez
17b88d0a6b Implement configuration and environments. 2016-10-03 03:39:56 -07:00
Sergio Benitez
4595338a39 Cache Cargo in Travis. 2016-09-30 15:39:55 -07:00
Sergio Benitez
008605bec7 This commit changes parsing traits and documents some of the core library:
* All From* trait methods are now named like the trait.
  * All From* traits have an associated Error type.
  * Document all of the `form` module.
  * Add codegen tests for auto-derived forms.
  * The param parsing traits now live under Request.
2016-09-30 01:25:07 -07:00
Sergio Benitez
9787085abf Fix examples for tweaked Template API. 2016-09-29 21:41:21 -07:00
Sergio Benitez
6fe2f51332 Add form kitchen sink example. 2016-09-28 19:31:26 -07:00
Sergio Benitez
b72ac78ce8 Add file test case for streaming. Fix streaming responder.
resolves #3
2016-09-25 04:07:03 -07:00
Sergio Benitez
cd4af6836a Add request preprocessing for _method in forms.
resolves #12
2016-09-25 02:26:15 -07:00