Commit Graph

48 Commits

Author SHA1 Message Date
Sergio Benitez
a1878ad080 Properly resolve dynamic segments, take 2.
Fixes #86.
2016-12-30 23:51:23 -06:00
Sergio Benitez
1f373cc83a Rename 'content_type' Route field to 'format'. 2016-12-30 20:15:28 -06:00
Sergio Benitez
dedf5094fe Remove URIBuf. 2016-12-21 00:20:14 -08:00
Sergio Benitez
62fe734492 URI uses Cow iternally. 2016-12-21 00:09:22 -08:00
Sergio Benitez
8d8d504b59 Document Config. Cleaner lib/handler docs. 2016-12-19 16:51:59 -08:00
Sergio Benitez
6815a56cb5 Rework Request: add lifetime to future proof, remove unsafe. 2016-12-16 03:07:23 -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
d7353c8c2d Document the Rocket type. Add expect method to Outcome. Add custom method to Rocket. 2016-11-04 14:35:04 +01:00
Sergio Benitez
6a8d64f69b Move the data module into the top-level namespace. 2016-10-25 13:24:07 +02:00
Sergio Benitez
5a1a303c59 Document the http module. 2016-10-17 19:29:58 -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
619b1d787e Rename Response::new to complete. Add Response::failure using newly added Failure response. 2016-10-08 20:53:04 -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
650d079b58 Make the uri parameter in Request private. 2016-10-06 00:08:00 -07:00
Sergio Benitez
647efe15d1 Move uri module into http namespace. 2016-10-03 17:25:27 -07:00
Sergio Benitez
74ec26db95 Namespace HTTP-related type under http. 2016-10-03 17:09:13 -07:00
Sergio Benitez
a29d56c52e Reform top-level libs mostly according to Rustfmt. 2016-09-30 15:20:11 -07:00
Sergio Benitez
e8e85f09cd Add support for flash cookie. Revamp cookie support. 2016-09-11 18:57:04 -07:00
Sergio Benitez
b755e53f63 Add trailing params. 2016-09-08 00:02:17 -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
4d301eebbd Complete overhaul complete. 2016-09-04 04:06:28 -07:00
Sergio Benitez
a42d7f8668 Complete rewrite of macro parsing and item generation. 2016-09-04 01:05:17 -07:00
Sergio Benitez
8b99016af4 Add rank to route attribute. Macrofy is_some ContentType methods. 2016-08-27 05:10:29 -07:00
Sergio Benitez
c058694bd0 Add more ranked routing tests. 2016-08-26 21:48:16 -07:00
Sergio Benitez
a34374d913 Output all matching routes, not just first ranked. 2016-08-26 21:34:28 -07:00
Sergio Benitez
860b302793 Change rank meaning: lower means higher priority. 2016-08-26 19:03:21 -07:00
Sergio Benitez
90d8621adf Major overhual: Request, ErrorHandler, ContentType. 2016-08-26 01:55:11 -07:00
Sergio Benitez
868448c4b3 Use log crate for cleaner, more flexible logging. 2016-08-24 01:30:09 -07:00
Sergio Benitez
b51cb22f87 Fix Route::ranked type signature. 2016-08-22 20:38:39 -07:00
Sergio Benitez
bd9d553050 New type: ContentType. Parse ContentType from attribute. 2016-08-22 20:34:22 -07:00
Sergio Benitez
578b50b1f9 Fully working todo example. Apparently didn't commit in a while. Need to be better at that. 2016-08-01 19:07:36 -07:00
Sergio Benitez
92671a0cba Overhealed route decorator. URI struct now understands query part. 2016-07-18 21:11:22 -07:00
Sergio Benitez
9db5f5811f Fixed all valid Clippy warnings. Removed deprecated method call. 2016-04-22 19:48:03 -07:00
Sergio Benitez
b8b44a0594 Can now assign outcome to response. Route mismatches now forward.
This means we have almost all of the infrastructure in place to properly use
ranked requests. At the moment, we only use this to allow user error handlers
when a responder fails. But, soon enough, we'll try the next highest ranked
route until there are no more matching routes. Yipee!
2016-04-11 03:57:23 -07:00
Sergio Benitez
3e449d2fb9 Forms are now working! 2016-04-03 21:53:25 -07:00
Sergio Benitez
293159904f Fixed codegen to work with new API. 2016-04-03 04:25:37 -07:00
Sergio Benitez
3dfa049a1a HRTB for the win! Manual routes example fully working. 2016-04-03 03:36:30 -07:00
Sergio Benitez
72329a7145 Adding/removing TODOs. 2016-04-02 01:51:22 -07:00
Sergio Benitez
416a18abf8 Added ranked routing. 2016-04-02 01:46:41 -07:00
Sergio Benitez
69a19ccc7f Trying to clean up that ugly function... 2016-04-02 00:58:06 -07:00
Sergio Benitez
5fb12485e8 Major refactoring. Merged two Route structure. Created URI and URIBuf. 2016-04-02 00:51:40 -07:00
Sergio Benitez
50bc0d6999 Major refactoring.
Here's the idea: under the `Rocket` namespace should live things critical to
writing simple Rocket apps: Request, Response, Error, etc. Nothing should be
nested more than one level deep. Only items required for more complex things
(implementing uncommon traits, etc.) should be nested one level deep.

This commit is the first attempt at realizing this.
2016-04-01 16:54:53 -07:00
Sergio Benitez
fb8fdc3bc2 Cleaned up response -> split into files. Started form example.
There's something going on with Hyper. When a 303 (see other) response is sent
in response to a POST, the browser does a GET to the location header. Hyper
somehow misreads the method parameter here, resulting in a route failer.

I need to MITM the connection to see exactly what the browser is sending and
what Hyper is receiving to see who's wrong.
2016-03-28 02:34:09 -07:00
Sergio Benitez
877b37c903 Polished examples directory. Fixed File response bug. 2016-03-22 16:27:12 -07:00
Sergio Benitez
433a9119bd It works! Next steps: clean-up, error handling, docs. 2016-03-21 22:04:39 -07:00
Sergio Benitez
5cdb645fc9 Routing is functional! Sort-of. Pretty console colors.
Okay, so, given a URI, we can figure out which route is corresponds to.
Unfortunately, the handler is not yet part of that route, and we're not parsing
the parameters from the path quite yet. But, we're almost there!
2016-03-21 02:22:22 -07:00
Sergio Benitez
b2fbf0d6bd Split up router file into multiple files. Route Collider for strings to Route. 2016-03-20 21:27:17 -07:00