Commit Graph

325 Commits

Author SHA1 Message Date
Sergio Benitez e2fcd75325 Use forked compiletest for latest nightly. 2016-12-16 15:14:11 -08:00
Sergio Benitez 2e25ce04dc Automatically handle HEAD requests. 2016-12-16 05:17:16 -08:00
Sergio Benitez 6815a56cb5 Rework Request: add lifetime to future proof, remove unsafe. 2016-12-16 03:07:23 -08:00
Sergio Benitez 5f311c3654 Implement Responder for Response. 2016-12-15 20:57:14 -08:00
Sergio Benitez 368e5105a9 Return a Response from testing's dispatch_with. 2016-12-15 20:53:54 -08:00
Sergio Benitez 77cfed0d21 Fix minor README/comment typos. 2016-12-15 17:22:33 -08:00
Sergio Benitez 08f41816d1 Remove dependence from Hyper in Request/MockRequest. 2016-12-15 16:34:19 -08:00
Sergio Benitez a73a082153 New HeaderMap type for grouping Headers. 2016-12-15 12:37:17 -08:00
Sergio Benitez d3e2d829c7 Remove all Hyper* types in favor of hyper::*. 2016-12-15 09:24:29 -08:00
Sergio Benitez 0cc379b82f Parse and test params in ContentType. 2016-12-15 08:49:10 -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 5fca86c84f New version: 0.0.11. 2016-12-11 22:23:08 -08:00
Sergio Benitez 6bc0fa8871 Make note about implementing auto HEAD handling. 2016-12-11 21:20:30 -08:00
Sergio Benitez e6fa01607f Link to Stream in Responder docs. 2016-12-11 01:40:03 -08:00
Sergio Benitez 3dc82e2349 HTML escape < in Responder docs. 2016-12-10 17:58:52 -08:00
Sergio Benitez 4f89e232aa HTML escape < in FromParam docs. 2016-12-10 17:41:44 -08:00
Sergio Benitez 470dc7f63c Improve FromParam documentation. 2016-12-10 02:55:25 -08:00
Sergio Benitez a818976b08 Add example implementation for Responder. 2016-12-09 20:59:58 -08:00
Sergio Benitez d0136235d7 Remove with_status and StatusResponder in favor of status module. 2016-12-09 19:53:13 -08:00
Sergio Benitez a2e99985b0 Fix data buffer indexing bug. Add from_request example. 2016-11-21 00:45:44 -08:00
Sergio Benitez b38942ad00 Avoid double logger initialization by removing logger init in Rocket::custom. 2016-11-11 14:04:00 -08:00
Sergio Benitez ba88fcdc95 Document FromRequest. Clarify FromFormValue::default. 2016-11-06 17:07:47 +01:00
Sergio Benitez 006a35a8a9 Add an example to Rocket::catch docs. 2016-11-05 19:35:21 +01: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 a5599aac9c Hide all of the logger macros, for now. 2016-11-04 15:38:06 +01:00
Sergio Benitez 4d189df884 Fix the tests for latest changes. 2016-11-04 15:11:59 +01: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 dd030334e4 Document the Error type. 2016-11-03 19:00:52 +01:00
Sergio Benitez 32e22fc8e1 Document the content module, complete response documentation. 2016-11-03 18:54:37 +01:00
Sergio Benitez 553082f026 Document all of the core response types. 2016-11-03 17:05:41 +01:00
Sergio Benitez 129268506e Document Responder. Further document Flash. Implement Debug for most Responder types. 2016-11-03 15:09:01 +01:00
Sergio Benitez c2d3bdccdb Document the Failure and Flash responses. 2016-11-02 18:48:43 +01:00
Sergio Benitez 004cae7627 Fix codegen tests for new lib. Make UTF8 charset the default for text content types. 2016-11-02 17:39:41 +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 4326c9103e Propogate error types in FromParam and FromSegment parses. 2016-10-31 18:51:19 +01:00
Sergio Benitez 639cd425ee Add Debug bound to associated parsing Errors. 2016-10-31 18:31:39 +01:00
Sergio Benitez 785d0d2a6a Fix URI display for root path. 2016-10-31 17:32:43 +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 5766766659 Use a 'Sync' type for the session key. 2016-10-25 17:07:39 +02:00
Sergio Benitez 25d55b4b0f Disallow use of data parameter with non-payload methods. 2016-10-25 16:42:10 +02:00
Sergio Benitez fb67681adc Don't reexport IntoOutcome trait. 2016-10-25 13:39:31 +02:00
Sergio Benitez 81113ecf50 Remove public qualification from private data modules. 2016-10-25 13:35:02 +02:00
Sergio Benitez 1849365eda Inline the Data struct in docs. 2016-10-25 13:27:16 +02: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 2f04027c5f Document the testing module. 2016-10-25 10:16:34 +02:00
Sergio Benitez 11b6158276 Refine request module API docs. 2016-10-24 10:09:50 +02:00
Sergio Benitez e70fcd78b9 Properly escape ticks for markdown in Form docs. 2016-10-21 09:06:40 -07:00
Sergio Benitez 2da43e24f7 Document most of the request module. 2016-10-21 02:56:57 -07:00
Sergio Benitez 81f45608a1 Document outcome module. 2016-10-19 00:30:02 -07:00
Sergio Benitez 2a0535e1f7 Document the config module. 2016-10-18 12:04:56 -07:00
Sergio Benitez 5a1a303c59 Document the http module. 2016-10-17 19:29:58 -07:00
Sergio Benitez 762b38efe9 Add fragment support to URI type. 2016-10-17 17:21:29 -07: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 33f0274f62 Remove unused Rocket::config method. 2016-10-16 03:21:34 -07:00
Sergio Benitez bc5ecb31df Implement a small testing framework in the 'testing' module. 2016-10-16 03:16:16 -07:00
Sergio Benitez 3008820494 Seperate request dispatch into hyper and non-hyper parts. 2016-10-16 00:03:08 -07:00
Sergio Benitez 471239c567 Protect the session_key from external libs. Clean-up config docs. 2016-10-15 18:58:57 -07:00
Sergio Benitez cf9f746ee2 Remove question_mark feature: it's been stabalized! 2016-10-14 19:07:22 -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 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 07204a25dd Remove Rocket::from_hyp in favor of Rocket::new. 2016-10-08 21:37:28 -07:00
Sergio Benitez a7b180c911 Remove Empty response. 2016-10-08 20:57:39 -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 0144b70fac Cleanup documentation related code. 2016-10-08 04:42:22 -07:00
Sergio Benitez e30e4e6c7f Make 'http' public. 2016-10-08 04:29:20 -07:00
Sergio Benitez c4b817ae0b Cleanup dispatch messages and comments. 2016-10-07 23:37:29 -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 59623d936f Add a default template for every known error code. 2016-10-07 21:31:52 -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 be3530bb44 Make Outcome generic on its encapsulated type. 2016-10-07 19:09:05 -07:00
Sergio Benitez 6578de4615 Always inline appropriate Request methods. 2016-10-06 21:04:35 -07:00
Sergio Benitez 39f7f2d32b Remove unneeded lifetime in Request.
Previously, a Request's only lifetime parameter referred to itself. This
causes many issues and is simply wrong. Instead, use `transmute` to make
the lifetime `static`. As long the contents inside Request don't move or
change, the references are valid. We keep the lifetime as a phantom in
`Request` for future use.
2016-10-06 20:57:17 -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 639a78a8d6 Add a bad_request response type. Use it when form's aren't utf8. 2016-10-06 00:16:15 -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 63d31e8082 Simplify a branch in check_config macro. 2016-10-04 15:05:25 -07:00
Sergio Benitez 2ad508ed96 Test config and environments.
resolves #11
2016-10-04 15:05:25 -07:00
Sergio Benitez 463df9d1df New version: 0.0.10. 2016-10-04 15:05:16 -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 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 17b88d0a6b Implement configuration and environments. 2016-10-03 03:39:56 -07:00
Sergio Benitez 39c979db4c Add library and usage information to main API doc. 2016-10-02 17:52:04 -07:00
Sergio Benitez 7dc6e432b8 Change wordering of ContentType structure docs. 2016-09-30 20:31:32 -07:00
Sergio Benitez 320f2e0efa Document Request. 2016-09-30 20:22:06 -07:00
Sergio Benitez 9e402dfd07 Revert visibility change in ContentType constructor. 2016-09-30 20:10:49 -07:00
Sergio Benitez 57f79ca867 Document ContentType. 2016-09-30 20:04:43 -07:00
Sergio Benitez a29d56c52e Reform top-level libs mostly according to Rustfmt. 2016-09-30 15:20:11 -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 76cbc14d23 Cleanup core library documentation. 2016-09-29 21:44:27 -07:00
Sergio Benitez 1c4e0350d9 Use strict version numbers. Bump Rocket version. 2016-09-29 20:49:18 -07:00
Sergio Benitez a6cd1bd5bd Clean-up form parsing tests. 2016-09-28 20:39:25 -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 b72ac78ce8 Add file test case for streaming. Fix streaming responder.
resolves #3
2016-09-25 04:07:03 -07:00
Sergio Benitez 5b5cb7e087 Send the correct content type in Template contrib. 2016-09-25 03:06:02 -07:00
Sergio Benitez b175de03ad Move extension derived content type into ContentType. 2016-09-25 02:51:18 -07:00
Sergio Benitez cd4af6836a Add request preprocessing for _method in forms.
resolves #12
2016-09-25 02:26:15 -07:00
Sergio Benitez a967018009 Add guide outline. Remove unused file. 2016-09-22 22:09:41 -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 53e5377482 Change meaning of Outcome::Bad. 2016-09-21 18:31:26 -07:00
Sergio Benitez 81fbc0625d Add Bad outcome. Mock config code. 2016-09-21 18:23:44 -07:00
Sergio Benitez 47edc65d34 Rename data_type to data and don't export inner types. 2016-09-20 20:02:33 -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 4e03bb6107 Add NamedFile response type. 2016-09-12 01:51:02 -07:00
Sergio Benitez 21e26c32c0 Bump version numbers. Approaching release! 2016-09-11 18:57:47 -07:00
Sergio Benitez e8e85f09cd Add support for flash cookie. Revamp cookie support. 2016-09-11 18:57:04 -07:00
Sergio Benitez 9a9d07f044 Improve default catcher error messages. 2016-09-09 01:00:51 -07:00
Sergio Benitez f259593727 Use a generic ToString object in new. 2016-09-08 00:25:40 -07:00
Sergio Benitez b755e53f63 Add trailing params. 2016-09-08 00:02:17 -07:00
Sergio Benitez a6967cb48f Strip lifetimes for generated param types. 2016-09-06 23:24:20 -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 7f54c9036f Return HTML for default catchers. 2016-09-04 14:24:36 -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 bb9faeb344 Version bump. 2016-08-27 05:34:06 -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 2fe13b2fe8 Clippyfied the library. 2016-08-26 22:05:33 -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 a1ad05e879 This commit is a squash of the following commits:
* Add content-type responsers for JSON, HTML, and plain text.
  * Use content-type responders in content_type example.
  * Conditionally create Request `from` HypRequest.
  * Clean-up dispatching and handling in main rocket.
  * Change Level enum to Logging Level and reexport.
  * Allow users to set logging level before launch.
  * Fix content_type example error handling.
  * Percent decode params when user requests `String`.
2016-08-26 18:37:28 -07:00
Sergio Benitez 90d8621adf Major overhual: Request, ErrorHandler, ContentType. 2016-08-26 01:55:11 -07:00
Sergio Benitez 81bc2466eb Add missing logger file. 2016-08-24 01:34:00 -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 3a89cb8e2b Can now retrieve cookies from a handler. SWEET! Bumped version to 0.0.5. 2016-08-08 03:48:00 -07:00
Sergio Benitez 95a8a51b76 Added FromRequest and modified macro to use it: any parameters not declared by the user in the attributes will automatically be retrieved using FromRequest. 2016-08-08 03:10:23 -07:00
Sergio Benitez bceb1ecfb6 Added Cookied as a response: can now set cookies. Added example of setting cookies. Working on retrieving them. 2016-08-06 23:14:05 -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 26b7b814f4 Progress on errors. Started Todo example.
The error function now takes in a "RoutingError" structure. The idea is that the
structure includes all of the information necessary for a user to processor the
error as they wish. This interface is very incomplete and may change. At a
minimum, the error structure should include:

  1) The request that failed.
  2) Why the request failed.
  3) The chain of attempted route matches, if any.
  4) Something else?
2016-07-15 21:09:08 -07:00
Sergio Benitez 9db5f5811f Fixed all valid Clippy warnings. Removed deprecated method call. 2016-04-22 19:48:03 -07:00
Sergio Benitez d1a54e9c0e Remove unnecessary mut. 2016-04-11 04:02:39 -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 3f2954ab5c Added Response::with_status. Using it for catchers. 2016-04-11 02:12:45 -07:00
Sergio Benitez 1ef7a15bab Working error handling! Not quite there yet though.
A few important things needs to get this to be 'right':
  1a. Have a way to return a response with a status code.
  1b. Use that mechanism in the default catchers.
  2. Automatically fill in that code from the #[error] handler.
  3. Have a way for a responder to say if responding succeeded.
  4. Try next highest ranking route if responding with one handler fails.
2016-04-06 13:50:02 -07:00
Sergio Benitez dc5ef6a421 Progress on error handling. Calling them 'catchers' for now.
Added `error` decorator and `errors` macro.

The current idea is that you can have "catchers" for all valid errors code (in
range [400, 500). At the moment, catchers are just request handlers, and the
decorator expected an empty function signature for the error handler. Obviously,
this is pretty useless. Not sure on what the API should be here. But, progress.

Oh, one more thing: who should handle forwarding a request to a catcher?
Probably not the router. So, the main Rocket should?
2016-04-06 03:26:43 -07:00
Sergio Benitez 2dbcfa10e3 Implemented FromFormValue for all of the FromStrs. 2016-04-04 04:19:07 -07:00
Sergio Benitez b76dc137d3 Forgot to add the form file. Whoops. 2016-04-03 22:56:36 -07:00
Sergio Benitez b7d22d58f7 Actually useful forms! 2016-04-03 22:41:31 -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 d477c18062 Major progress towards form support. 2016-03-30 01:02:21 -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 cddc92f870 Now support Result responses.
Experimented with the new impl specialization features of Rust. They work! But
they're not quite there yet. Specifically, I was able to specialize on
`Responder`, but when trying to remove the macro in `FromParam`, it didn't work.
See https://github.com/rust-lang/rust/issues/31844.
2016-03-22 17:16:17 -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
Sergio Benitez 3764afbf1e Cleaned up routing code. It's nearing completion!
* Should be able to write a simple O(n) router using the collision functions.
* Still need to split things up into multiple files.
2016-03-18 19:05:29 -07:00
Sergio Benitez 40559736fc Cleaned up to get rid of warnings. 2016-03-17 20:37:34 -07:00
Sergio Benitez 852120e23a Forgot a file, it seems. 2016-03-17 19:43:58 -07:00
Sergio Benitez 2a58800b35 initial implementation of collision detection in routing. 2016-03-17 03:29:55 -07:00
Sergio Benitez da2b0ed35a Somewhat good infrastructure for params and responses.
Can actually return strings and what-not from a route. Yay!
2016-03-17 01:57:04 -07:00
Sergio Benitez c6e8cd47da Notes on a perhaps better Body. 2016-03-15 00:47:03 -07:00
Sergio Benitez dcb150bde7 Something works! A simple hacked-up handler, that is.
At the moment, I simply install the first route I see into the Rocket struct
directly. This is quite terrible. What's worse is that I assume that the Route's
path and handler are static! The handler, actually, does have to be static, but
its response may have whatever (valid) lifetime, though I'm not sure anything
but `static makes sense. I'll think about it.

In any case, the weird `static` restrictions need to be removed, and I need to
think about which lifetimes are safe here. IE: Must all routes be static? Can I
use a closure as a route? (that'd be neat). If so, how do we make that work?

In any case, it's nice to see SOMETHING work. Yay!
2016-03-15 00:41:22 -07:00
Sergio Benitez ad08fe1d04 Major changes. FN params are now being used! Woo!
Subset of list of changes:
  * Split up decorator and macro into their own files.
  * Fully parsing the path parameter and verifying against the function's args.
  * Actually calling methods to fetch and convert the request parameters.
  * Actually calling methods to convert the handler's return type.
  * Sketched out more of the Request/Response structures.

Pretty close to having a fully working MVP.
2016-03-14 20:43:52 -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