Skip to content

Commit

Permalink
Reimplement route attribute as a proc-macro.
Browse files Browse the repository at this point in the history
This commits also implement the query reform from #608. It also consists
of many, many breaking changes. Among them are:

  * Query parts in route paths use new query reform syntax.
  * Routing for queries is now lenient.
    - Default ranking has changed to reflect query reform.
  * Format routing matching has been fixed.
    - Routes with formats matching "accept" will always collide.
    - Routes with formats matching "content-type" require requests to
      have an equivalent content-type header to match.
    - Requests with imprecise content-types are treated as not having a
      content-type.
  * Generated routes and catchers respect visibility modifiers.
  * Raw getter methods from request were renamed and retooled.
    - In particular, the index parameter is based on segments in the
      route path, not dynamic parameters.
  * The method-based attributes no longer accept a keyed 'path'.
  * The 'rocket_codegen' crate is gone and will no longer be public.
  * The 'FormItems' iterator emits values of type 'FormItem'.
    - The internal form items' string can no longer be retrieved.
  * In general, routes are more strictly validated.
  * Logging from codegen now funnels through logging infrastructure.
  * Routing has been optimized by caching routing metadata.

Resolves #93.
Resolves #608.
Resolves #693.
Resolves #476.
  • Loading branch information
SergioBenitez committed Oct 9, 2018
1 parent 3eb873d commit 61f107f
Show file tree
Hide file tree
Showing 164 changed files with 2,829 additions and 2,504 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ Rocket is web framework for Rust (nightly) with a focus on ease-of-use,
expressibility, and speed. Here's an example of a complete Rocket application:

```rust
#![feature(plugin, decl_macro)]
#![plugin(rocket_codegen)]
#![feature(proc_macro_non_items, proc_macro_gen, decl_macro)]

#[macro_use] extern crate rocket;

Expand Down
8 changes: 4 additions & 4 deletions contrib/codegen/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ pub fn database_attr(attr: TokenStream, input: TokenStream) -> Result<TokenStrea
match pool {
Ok(Ok(p)) => Ok(rocket.manage(#pool_type(p))),
Err(config_error) => {
::rocket::logger::log_err(false,
::rocket::logger::log_error(
&format!("Database configuration failure: '{}'", #name));
::rocket::logger::log_err(true, &format!("{}", config_error));
::rocket::logger::log_error_(&format!("{}", config_error));
Err(rocket)
},
Ok(Err(pool_error)) => {
::rocket::logger::log_err(false,
::rocket::logger::log_error(
&format!("Failed to initialize pool for '{}'", #name));
::rocket::logger::log_err(true, &format!("{:?}", pool_error));
::rocket::logger::log_error_(&format!("{:?}", pool_error));
Err(rocket)
},
}
Expand Down
4 changes: 2 additions & 2 deletions contrib/lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
//! This crate is expected to grow with time, bringing in outside crates to be
//! officially supported by Rocket.
#[macro_use] extern crate log;
#[macro_use] extern crate rocket;
#[allow(unused_imports)] #[macro_use] extern crate log;
#[allow(unused_imports)] #[macro_use] extern crate rocket;

#[cfg(feature = "serde")]
extern crate serde;
Expand Down
3 changes: 0 additions & 3 deletions core/codegen/src/decorators/mod.rs

This file was deleted.

Loading

0 comments on commit 61f107f

Please sign in to comment.