Commit Graph

50 Commits

Author SHA1 Message Date
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
a4f56f1790 Don't repeat parsing of path. 2016-09-04 14:50:14 -07:00
Sergio Benitez
fec443a3f0 Fix issue #1. 2016-09-04 13:51:16 -07:00
Sergio Benitez
529340ebb7 Add missing comma to quote_enum macro. 2016-09-04 13:34:11 -07:00
Sergio Benitez
f54b39584d Renamed method_variant_to_expr to method_to_path. 2016-09-04 04:22:43 -07:00
Sergio Benitez
5722e9453e Removed unncessary code. 2016-09-04 04:10:10 -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
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
2b7b733e83 Remove denig: it is not a macro. 2016-08-25 19:08:56 -07:00
Sergio Benitez
a5e1f8246c Revert parsing bug introduced in commit 43bfefc1b2. 2016-08-25 19:02:26 -07:00
Sergio Benitez
868448c4b3 Use log crate for cleaner, more flexible logging. 2016-08-24 01:30:09 -07:00
Sergio Benitez
43bfefc1b2 Switch to UFCS in param.contains call. 2016-08-23 23:23:57 -07:00
Sergio Benitez
bd9d553050 New type: ContentType. Parse ContentType from attribute. 2016-08-22 20:34:22 -07:00
Sergio Benitez
c8eef33820 Renamed to 'data' to 'content_type'. 2016-08-22 19:21:59 -07:00
Sergio Benitez
8adf9f7c46 Parse 'data' parameter in route attribute. 2016-08-22 19:13:36 -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
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
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
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
d0dd49f98d Implemented FromForm derivation. Woo! 2016-04-04 04:14:18 -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
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
433a9119bd It works! Next steps: clean-up, error handling, docs. 2016-03-21 22:04:39 -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
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
Sergio Benitez
967fcd26b2 Initial commit. Checking for method and path arguments in route. Not storing the info anywhere yet. 2016-03-07 11:28:04 -08:00