1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-28 01:32:57 +01:00

implement Debug for Form, Query, Path extractors

This commit is contained in:
Nikolay Kim 2018-06-02 14:58:15 -07:00
parent 698f0a1849
commit 7e0706a942

View File

@ -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<T: fmt::Debug> fmt::Debug for Path<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.inner.fmt(f)
}
}
impl<T: fmt::Display> fmt::Display for Path<T> {
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<S>, _: &Self::Config) -> Self::Result {
let req = req.clone();
serde_urlencoded::from_str::<T>(req.query_string())
.map_err(|e| e.into())
.map(Query)
}
}
impl<T: fmt::Debug> fmt::Debug for Query<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.0.fmt(f)
}
}
impl<T: fmt::Display> fmt::Display for Query<T> {
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<T: fmt::Debug> fmt::Debug for Form<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.0.fmt(f)
}
}
impl<T: fmt::Display> fmt::Display for Form<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.0.fmt(f)
}
}
/// Form extractor configuration
///
/// ```rust