mirror of https://github.com/rwf2/Rocket.git
Move the data module into the top-level namespace.
This commit is contained in:
parent
f5a5ea3a22
commit
6a8d64f69b
|
@ -104,7 +104,7 @@ impl RouteGenerateExt for RouteParams {
|
||||||
let ty = strip_ty_lifetimes(arg.ty.clone());
|
let ty = strip_ty_lifetimes(arg.ty.clone());
|
||||||
Some(quote_stmt!(ecx,
|
Some(quote_stmt!(ecx,
|
||||||
let $name: $ty =
|
let $name: $ty =
|
||||||
match ::rocket::request::FromData::from_data(&_req, _data) {
|
match ::rocket::data::FromData::from_data(&_req, _data) {
|
||||||
::rocket::outcome::Outcome::Success(d) => d,
|
::rocket::outcome::Outcome::Success(d) => d,
|
||||||
::rocket::outcome::Outcome::Forward(d) =>
|
::rocket::outcome::Outcome::Forward(d) =>
|
||||||
return ::rocket::Response::forward(d),
|
return ::rocket::Response::forward(d),
|
||||||
|
|
|
@ -5,7 +5,8 @@ use std::ops::{Deref, DerefMut};
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
|
||||||
use rocket::outcome::{Outcome, IntoOutcome};
|
use rocket::outcome::{Outcome, IntoOutcome};
|
||||||
use rocket::request::{data, Request, Data, FromData};
|
use rocket::request::Request;
|
||||||
|
use rocket::data::{self, Data, FromData};
|
||||||
use rocket::response::{self, Responder, content};
|
use rocket::response::{self, Responder, content};
|
||||||
use rocket::http::StatusCode;
|
use rocket::http::StatusCode;
|
||||||
use rocket::http::hyper::FreshHyperResponse;
|
use rocket::http::hyper::FreshHyperResponse;
|
||||||
|
|
|
@ -5,7 +5,7 @@ extern crate rocket;
|
||||||
|
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
use rocket::request::Data;
|
use rocket::Data;
|
||||||
use rocket::response::content::Plain;
|
use rocket::response::content::Plain;
|
||||||
|
|
||||||
#[post("/upload", format = "text/plain", data = "<data>")]
|
#[post("/upload", format = "text/plain", data = "<data>")]
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
use outcome::{self, IntoOutcome};
|
use outcome::{self, IntoOutcome};
|
||||||
use outcome::Outcome::*;
|
use outcome::Outcome::*;
|
||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
use request::{Request, Data};
|
use request::Request;
|
||||||
|
use data::Data;
|
||||||
|
|
||||||
/// Type alias for the `Outcome` of a `FromData` conversion.
|
/// Type alias for the `Outcome` of a `FromData` conversion.
|
||||||
pub type Outcome<S, E> = outcome::Outcome<S, (StatusCode, E), Data>;
|
pub type Outcome<S, E> = outcome::Outcome<S, (StatusCode, E), Data>;
|
|
@ -1,4 +1,4 @@
|
||||||
//! Talk about the data thing.
|
//! Types and traits for reading and parsing request body data.
|
||||||
|
|
||||||
#[cfg(any(test, feature = "testing"))] pub mod test_data;
|
#[cfg(any(test, feature = "testing"))] pub mod test_data;
|
||||||
#[cfg(not(any(test, feature = "testing")))] pub mod data;
|
#[cfg(not(any(test, feature = "testing")))] pub mod data;
|
|
@ -102,6 +102,7 @@ pub mod request;
|
||||||
pub mod response;
|
pub mod response;
|
||||||
pub mod outcome;
|
pub mod outcome;
|
||||||
pub mod config;
|
pub mod config;
|
||||||
|
pub mod data;
|
||||||
|
|
||||||
mod error;
|
mod error;
|
||||||
mod router;
|
mod router;
|
||||||
|
@ -112,7 +113,8 @@ mod catcher;
|
||||||
/// Defines the types for request and error handlers.
|
/// Defines the types for request and error handlers.
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub mod handler {
|
pub mod handler {
|
||||||
use request::{Request, Data};
|
use data::Data;
|
||||||
|
use request::Request;
|
||||||
use response::Response;
|
use response::Response;
|
||||||
use error::Error;
|
use error::Error;
|
||||||
|
|
||||||
|
@ -127,12 +129,13 @@ pub mod handler {
|
||||||
#[doc(inline)] pub use handler::{Handler, ErrorHandler};
|
#[doc(inline)] pub use handler::{Handler, ErrorHandler};
|
||||||
#[doc(inline)] pub use logger::LoggingLevel;
|
#[doc(inline)] pub use logger::LoggingLevel;
|
||||||
#[doc(hidden)] pub use codegen::{StaticRouteInfo, StaticCatchInfo};
|
#[doc(hidden)] pub use codegen::{StaticRouteInfo, StaticCatchInfo};
|
||||||
|
#[doc(inline)] pub use outcome::{Outcome, IntoOutcome};
|
||||||
pub use router::Route;
|
pub use router::Route;
|
||||||
pub use request::{Request, Data};
|
pub use request::Request;
|
||||||
|
pub use data::Data;
|
||||||
pub use error::Error;
|
pub use error::Error;
|
||||||
pub use catcher::Catcher;
|
pub use catcher::Catcher;
|
||||||
pub use rocket::Rocket;
|
pub use rocket::Rocket;
|
||||||
pub use outcome::{Outcome, IntoOutcome};
|
|
||||||
|
|
||||||
/// Alias to Rocket::ignite().
|
/// Alias to Rocket::ignite().
|
||||||
pub fn ignite() -> Rocket {
|
pub fn ignite() -> Rocket {
|
||||||
|
|
|
@ -28,7 +28,8 @@ use std::fmt::{self, Debug};
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
|
||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
use request::{data, Request, FromData, Data};
|
use request::Request;
|
||||||
|
use data::{self, Data, FromData};
|
||||||
use outcome::Outcome::*;
|
use outcome::Outcome::*;
|
||||||
|
|
||||||
// TODO: This works and is safe, but the lifetime appears twice.
|
// TODO: This works and is safe, but the lifetime appears twice.
|
||||||
|
|
|
@ -1,28 +1,11 @@
|
||||||
//! Types and traits for request parsing and handling.
|
//! Types and traits for request parsing and handling.
|
||||||
//!
|
|
||||||
//! # Request and Data
|
|
||||||
//!
|
|
||||||
//! The [Request](struct.Request.html) and [Data](struct.Data.html) types
|
|
||||||
//! contain all of the available information for an incoming request. The
|
|
||||||
//! `Request` types contains all information _except_ the body, which is
|
|
||||||
//! contained in the `Data` type.
|
|
||||||
//!
|
|
||||||
//! # Code Generation Conversion Traits
|
|
||||||
//!
|
|
||||||
//! This module contains the core code generation data conversion traits. These
|
|
||||||
//! traits are used by Rocket's code generation facilities to automatically
|
|
||||||
//! derive values from incoming data based on the signature of a request
|
|
||||||
//! handler.
|
|
||||||
|
|
||||||
mod request;
|
mod request;
|
||||||
mod param;
|
mod param;
|
||||||
mod form;
|
mod form;
|
||||||
mod from_request;
|
mod from_request;
|
||||||
|
|
||||||
pub mod data;
|
|
||||||
|
|
||||||
pub use self::request::Request;
|
pub use self::request::Request;
|
||||||
pub use self::from_request::{FromRequest, Outcome};
|
pub use self::from_request::{FromRequest, Outcome};
|
||||||
pub use self::param::{FromParam, FromSegments};
|
pub use self::param::{FromParam, FromSegments};
|
||||||
pub use self::form::{Form, FromForm, FromFormValue, FormItems};
|
pub use self::form::{Form, FromForm, FromFormValue, FormItems};
|
||||||
pub use self::data::{Data, FromData};
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use request::Data;
|
use data::Data;
|
||||||
use outcome::{self, Outcome};
|
use outcome::{self, Outcome};
|
||||||
use http::hyper::StatusCode;
|
use http::hyper::StatusCode;
|
||||||
use response::{Responder, StatusResponse};
|
use response::{Responder, StatusResponse};
|
||||||
|
|
|
@ -8,7 +8,8 @@ use term_painter::ToStyle;
|
||||||
|
|
||||||
use config;
|
use config;
|
||||||
use logger;
|
use logger;
|
||||||
use request::{Request, Data, FormItems};
|
use request::{Request, FormItems};
|
||||||
|
use data::Data;
|
||||||
use response::Responder;
|
use response::Responder;
|
||||||
use router::{Router, Route};
|
use router::{Router, Route};
|
||||||
use catcher::{self, Catcher};
|
use catcher::{self, Catcher};
|
||||||
|
|
|
@ -49,7 +49,8 @@ mod tests {
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use router::Collider;
|
use router::Collider;
|
||||||
use request::{Request, Data};
|
use request::Request;
|
||||||
|
use data::Data;
|
||||||
use response::Response;
|
use response::Response;
|
||||||
use router::route::Route;
|
use router::route::Route;
|
||||||
use http::{Method, ContentType};
|
use http::{Method, ContentType};
|
||||||
|
|
|
@ -43,8 +43,7 @@
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use outcome::Outcome::*;
|
use outcome::Outcome::*;
|
||||||
use http::{hyper, Method};
|
use http::{hyper, Method};
|
||||||
use request::{Request, Data};
|
use {Rocket, Request, Data};
|
||||||
use Rocket;
|
|
||||||
|
|
||||||
/// A type for mocking requests for testing Rocket applications.
|
/// A type for mocking requests for testing Rocket applications.
|
||||||
pub struct MockRequest {
|
pub struct MockRequest {
|
||||||
|
|
Loading…
Reference in New Issue