From 7e0706a9426708e60df412558f17f34785c8441e Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sat, 2 Jun 2018 14:58:15 -0700 Subject: [PATCH] implement Debug for Form, Query, Path extractors --- src/extractor.rs | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/extractor.rs b/src/extractor.rs index 3d77853a5..175e948b8 100644 --- a/src/extractor.rs +++ b/src/extractor.rs @@ -1,6 +1,6 @@ use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; -use std::str; +use std::{fmt, str}; use bytes::Bytes; use encoding::all::UTF_8; @@ -115,6 +115,18 @@ where } } +impl fmt::Debug for Path { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.inner.fmt(f) + } +} + +impl fmt::Display for Path { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.inner.fmt(f) + } +} + /// Extract typed information from from the request's query. /// /// ## Example @@ -175,13 +187,24 @@ where #[inline] fn from_request(req: &HttpRequest, _: &Self::Config) -> Self::Result { - let req = req.clone(); serde_urlencoded::from_str::(req.query_string()) .map_err(|e| e.into()) .map(Query) } } +impl fmt::Debug for Query { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.0.fmt(f) + } +} + +impl fmt::Display for Query { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.0.fmt(f) + } +} + /// Extract typed information from the request's body. /// /// To extract typed information from request's body, the type `T` must @@ -252,6 +275,18 @@ where } } +impl fmt::Debug for Form { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.0.fmt(f) + } +} + +impl fmt::Display for Form { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.0.fmt(f) + } +} + /// Form extractor configuration /// /// ```rust