mirror of https://github.com/rwf2/Rocket.git
Move the form module under request and outcome to top-level.
This commit is contained in:
parent
916bf7310a
commit
37e6a367b8
|
@ -68,7 +68,7 @@ pub fn from_form_derive(ecx: &mut ExtCtxt, span: Span, meta_item: &MetaItem,
|
|||
span: span,
|
||||
attributes: Vec::new(),
|
||||
path: ty::Path {
|
||||
path: vec!["rocket", "form", "FromForm"],
|
||||
path: vec!["rocket", "request", "FromForm"],
|
||||
lifetime: lifetime_var,
|
||||
params: vec![],
|
||||
global: true,
|
||||
|
@ -169,7 +169,7 @@ fn from_form_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substruct
|
|||
let id_str = ident_string.as_str();
|
||||
arms.push(quote_tokens!(cx,
|
||||
$id_str => {
|
||||
$ident = match ::rocket::form::FromFormValue::from_form_value(v) {
|
||||
$ident = match ::rocket::request::FromFormValue::from_form_value(v) {
|
||||
Ok(v) => Some(v),
|
||||
Err(e) => {
|
||||
println!("\tError parsing form val '{}': {:?}", $id_str, e);
|
||||
|
@ -183,7 +183,7 @@ fn from_form_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substruct
|
|||
// The actual match statement. Iterate through all of the fields in the form
|
||||
// and use the $arms generated above.
|
||||
stmts.push(quote_stmt!(cx,
|
||||
for (k, v) in ::rocket::form::FormItems($arg) {
|
||||
for (k, v) in ::rocket::request::FormItems($arg) {
|
||||
match k {
|
||||
$arms
|
||||
_ => {
|
||||
|
@ -205,7 +205,7 @@ fn from_form_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substruct
|
|||
|
||||
failure_conditions.push(quote_tokens!(cx,
|
||||
if $ident.is_none() &&
|
||||
<$ty as ::rocket::form::FromFormValue>::default().is_none() {
|
||||
<$ty as ::rocket::request::FromFormValue>::default().is_none() {
|
||||
println!("\t'{}' did not parse.", stringify!($ident));
|
||||
true
|
||||
} else { false }
|
||||
|
@ -218,7 +218,7 @@ fn from_form_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substruct
|
|||
for &(ref ident, ty) in &fields_and_types {
|
||||
result_fields.push(quote_tokens!(cx,
|
||||
$ident: $ident.unwrap_or_else(||
|
||||
<$ty as ::rocket::form::FromFormValue>::default().unwrap()
|
||||
<$ty as ::rocket::request::FromFormValue>::default().unwrap()
|
||||
),
|
||||
));
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ impl RouteGenerateExt for RouteParams {
|
|||
let ty = strip_ty_lifetimes(arg.ty.clone());
|
||||
Some(quote_stmt!(ecx,
|
||||
let $name: $ty =
|
||||
match ::rocket::form::FromForm::from_form_string($form_string) {
|
||||
match ::rocket::request::FromForm::from_form_string($form_string) {
|
||||
Ok(v) => v,
|
||||
Err(_) => return ::rocket::Response::forward()
|
||||
};
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
extern crate rocket;
|
||||
|
||||
use rocket::form::FromForm;
|
||||
use rocket::request::{FromForm, FromFormValue};
|
||||
|
||||
#[derive(Debug, PartialEq, FromForm)]
|
||||
struct TodoTask {
|
||||
|
@ -17,8 +17,6 @@ enum FormOption {
|
|||
A, B, C
|
||||
}
|
||||
|
||||
use rocket::form::FromFormValue;
|
||||
|
||||
impl<'v> FromFormValue<'v> for FormOption {
|
||||
type Error = &'v str;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ extern crate rocket;
|
|||
mod files;
|
||||
|
||||
use rocket::response::Redirect;
|
||||
use rocket::form::FromFormValue;
|
||||
use rocket::request::FromFormValue;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct StrongPassword<'r>(&'r str);
|
||||
|
|
|
@ -3,9 +3,8 @@
|
|||
|
||||
extern crate rocket;
|
||||
|
||||
use rocket::Request;
|
||||
use rocket::request::{Request, FromFormValue};
|
||||
use rocket::response::NamedFile;
|
||||
use rocket::form::FromFormValue;
|
||||
use std::io;
|
||||
|
||||
// TODO: Make deriving `FromForm` for this enum possible.
|
||||
|
|
|
@ -6,7 +6,7 @@ extern crate rocket;
|
|||
extern crate serde_json;
|
||||
#[macro_use] extern crate serde_derive;
|
||||
|
||||
use rocket::{Request, Error};
|
||||
use rocket::{Request};
|
||||
use rocket::response::Redirect;
|
||||
use rocket_contrib::Template;
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ extern crate serde_json;
|
|||
#[macro_use] extern crate rocket_contrib;
|
||||
#[macro_use] extern crate serde_derive;
|
||||
|
||||
use rocket::{Request, Error};
|
||||
use rocket_contrib::JSON;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Mutex;
|
||||
|
|
|
@ -70,9 +70,9 @@ extern crate toml;
|
|||
|
||||
#[doc(hidden)] #[macro_use] pub mod logger;
|
||||
#[doc(hidden)] pub mod http;
|
||||
pub mod form;
|
||||
pub mod request;
|
||||
pub mod response;
|
||||
pub mod outcome;
|
||||
|
||||
mod error;
|
||||
mod router;
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
use std::io::Read;
|
||||
|
||||
pub struct Data {
|
||||
stream: Box<Read>
|
||||
}
|
||||
|
||||
pub trait FromData {
|
||||
fn from_data(data: Data) -> Outcome { }
|
||||
}
|
|
@ -71,7 +71,7 @@ impl<'f> FromForm<'f> for &'f str {
|
|||
/// might define a new type and implement `FromFormValue` as follows:
|
||||
///
|
||||
/// ```rust
|
||||
/// use rocket::form::FromFormValue;
|
||||
/// use rocket::request::FromFormValue;
|
||||
/// use rocket::Error;
|
||||
///
|
||||
/// struct AdultAge(usize);
|
||||
|
@ -210,7 +210,7 @@ impl<'v, T: FromFormValue<'v>> FromFormValue<'v> for Result<T, T::Error> {
|
|||
/// `FormItems` can be used directly as an iterator:
|
||||
///
|
||||
/// ```rust
|
||||
/// use rocket::form::FormItems;
|
||||
/// use rocket::request::FormItems;
|
||||
///
|
||||
/// // prints "greeting = hello" then "username = jake"
|
||||
/// let form_string = "greeting=hello&username=jake";
|
||||
|
@ -222,7 +222,7 @@ impl<'v, T: FromFormValue<'v>> FromFormValue<'v> for Result<T, T::Error> {
|
|||
/// This is the same example as above, but the iterator is used explicitly.
|
||||
///
|
||||
/// ```rust
|
||||
/// use rocket::form::FormItems;
|
||||
/// use rocket::request::FormItems;
|
||||
///
|
||||
/// let form_string = "greeting=hello&username=jake";
|
||||
/// let mut items = FormItems(form_string);
|
|
@ -2,8 +2,10 @@
|
|||
|
||||
mod request;
|
||||
mod param;
|
||||
mod form;
|
||||
mod from_request;
|
||||
|
||||
pub use self::request::Request;
|
||||
pub use self::from_request::FromRequest;
|
||||
pub use self::param::{FromParam, FromSegments};
|
||||
pub use self::form::{FromForm, FromFormValue, FormItems};
|
||||
|
|
|
@ -2,7 +2,6 @@ mod empty;
|
|||
mod responder;
|
||||
mod redirect;
|
||||
mod with_status;
|
||||
mod outcome;
|
||||
mod flash;
|
||||
mod named_file;
|
||||
mod stream;
|
||||
|
@ -13,11 +12,11 @@ pub use self::responder::Responder;
|
|||
pub use self::empty::{Empty, Forward};
|
||||
pub use self::redirect::Redirect;
|
||||
pub use self::with_status::StatusResponse;
|
||||
pub use self::outcome::{Outcome, ResponseOutcome};
|
||||
pub use self::flash::Flash;
|
||||
pub use self::named_file::NamedFile;
|
||||
pub use self::stream::Stream;
|
||||
pub use self::data::Content;
|
||||
pub use outcome::{Outcome, ResponseOutcome};
|
||||
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use http::hyper::StatusCode;
|
||||
|
|
|
@ -8,11 +8,10 @@ use term_painter::ToStyle;
|
|||
|
||||
use config;
|
||||
use logger;
|
||||
use request::Request;
|
||||
use request::{Request, FormItems};
|
||||
use router::{Router, Route};
|
||||
use catcher::{self, Catcher};
|
||||
use response::Outcome;
|
||||
use form::FormItems;
|
||||
use outcome::Outcome;
|
||||
use error::Error;
|
||||
|
||||
use http::Method;
|
||||
|
|
Loading…
Reference in New Issue