From e1d2536d85e5dc334b9ba02a94de5345839a89ac Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Wed, 28 Mar 2018 14:34:17 -0700 Subject: [PATCH] remove unused code --- src/extractor.rs | 104 ----------------------------------------------- 1 file changed, 104 deletions(-) diff --git a/src/extractor.rs b/src/extractor.rs index aca43562f..d6559196b 100644 --- a/src/extractor.rs +++ b/src/extractor.rs @@ -189,110 +189,6 @@ impl HttpRequestExtractor for Query } } -/// Extract typed information from from the request's path and query. -/// -/// `S` - application state type -/// -/// ## Example -/// -/// ```rust -/// # extern crate bytes; -/// # extern crate actix_web; -/// # extern crate futures; -/// #[macro_use] extern crate serde_derive; -/// # use actix_web::*; -/// use actix_web::PathAndQuery; -/// -/// /// Application state -/// struct State {} -/// -/// #[derive(Deserialize)] -/// struct PathParam { -/// username: String, -/// } -/// -/// #[derive(Deserialize)] -/// struct QueryParam { -/// count: u32, -/// } -/// -/// // use `with` extractor for query info -/// // this handler get called only if request's path contains `username` field -/// // and query contains `count` field -/// fn index(data: PathAndQuery) -> Result { -/// Ok(format!("Welcome {}!", data.path().username)) -/// } -/// -/// fn main() { -/// let app = Application::with_state(State{}).resource( -/// "/index.html", -/// |r| r.method(Method::GET).with(index)); // <- use `with` extractor -/// } -/// ``` -pub struct PathAndQuery{ - pitem: P, - qitem: Q, - req: HttpRequest, -} - -impl PathAndQuery { - - /// Path information - #[inline] - pub fn path(&self) -> &P { - &self.pitem - } - - /// Query information - #[inline] - pub fn query(&self) -> &Q { - &self.qitem - } - - /// Shared application state - #[inline] - pub fn state(&self) -> &S { - self.req.state() - } - - /// Incoming request - #[inline] - pub fn request(&self) -> &HttpRequest { - &self.req - } - - /// Deconstruct instance into a parts - pub fn into(self) -> (P, Q, HttpRequest) { - (self.pitem, self.qitem, self.req) - } -} - -impl HttpRequestExtractor for PathAndQuery - where T: de::DeserializeOwned, Q: de::DeserializeOwned, S: 'static -{ - type Result = FutureResult; - - #[inline] - fn extract(req: &HttpRequest) -> Self::Result { - let req = req.clone(); - - let qitem = match serde_urlencoded::from_str::(req.query_string()) - .map_err(|e| e.into()) - { - Ok(item) => item, - Err(err) => return result(Err(err)) - }; - let pitem = match de::Deserialize::deserialize(PathExtractor{req: &req}) - .map_err(|e| e.into()) - { - Ok(item) => item, - Err(err) => return result(Err(err)) - }; - - result(Ok(PathAndQuery{pitem, qitem, req})) - } -} - macro_rules! unsupported_type { ($trait_fn:ident, $name:expr) => { fn $trait_fn(self, _: V) -> Result