Commit Graph

1863 Commits

Author SHA1 Message Date
Sergio Benitez
df9b71bee7 Updated README to use method specific decorator. 2016-08-08 18:35:24 -07:00
Sergio Benitez
eabb5169de Added method specific macros. 2016-08-08 18:34:18 -07:00
Sergio Benitez
c7b1eebd20 Refactored parsing code into its own module. 2016-08-08 18:08:59 -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
55d5dd2b46 Hopefully a fix for the travis bash script. 2016-08-06 20:59:51 -07:00
Sergio Benitez
d16d9bd0d7 Fixed todo example. Testing script now bootstraps when needed. 2016-08-06 19:57:44 -07:00
Sergio Benitez
b767c1bdec Fixed Cargo.toml in todo for new diesel. Serde is still broken. 2016-08-05 21:57:55 -07:00
Sergio Benitez
c3f9e01af1 Added run notes to TODO. 2016-08-01 20:01:47 -07:00
Sergio Benitez
37cbceff67 Rust isn't subtyping lifetimes correctly, so we'll appease it. 2016-08-01 19:47:21 -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
677d7c49ea Slightly cleaner form argument parsing. 2016-07-19 20:09:35 -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
5870c2fe92 Updated for latest Rust nightly. 2016-07-06 17:09: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
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
0d3ef66774 Updates for latest Rust. 2016-04-11 01:18:42 -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
33c4d89614 Updated README. 2016-04-06 12:50:51 -07:00
Sergio Benitez
e00b1a535a Stricter error code checking. 2016-04-06 03:32:35 -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
6e3d23b5f0 Add that badge in. 2016-04-04 19:04:46 -07:00
Sergio Benitez
0041724aa4 Slightly cleaner form exmaple. 2016-04-04 19:02:51 -07:00
Sergio Benitez
2dbcfa10e3 Implemented FromFormValue for all of the FromStrs. 2016-04-04 04:19:07 -07:00
Sergio Benitez
d0dd49f98d Implemented FromForm derivation. Woo! 2016-04-04 04:14:18 -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
ba6caad7c8 A better README. 2016-04-03 04:28:09 -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
6ba67ae79a Accidentally broke optional_result example. Now fixed. 2016-03-30 14:04:00 -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
1e9c0789f6 Don't need the type since we use unwrap_or. 2016-03-22 16:28:45 -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