feat(server): add path() and query() to Request
Closes #896 Closes #897 BREAKING CHANGE: `RequestUri::AbsolutePath` variant is changed to a struct variant. Consider using `req.path()` or `req.query()` to get the relevant slice.
This commit is contained in:
committed by
Sean McArthur
parent
a228486a85
commit
8b3c120684
@@ -66,17 +66,25 @@ impl<'a, T> Request<'a, T> {
|
||||
#[inline]
|
||||
pub fn version(&self) -> &HttpVersion { &self.version }
|
||||
|
||||
/*
|
||||
/// The target path of this Request.
|
||||
#[inline]
|
||||
pub fn path(&self) -> Option<&str> {
|
||||
match *self.uri {
|
||||
RequestUri::AbsolutePath(ref s) => Some(s),
|
||||
RequestUri::AbsoluteUri(ref url) => Some(&url[::url::Position::BeforePath..]),
|
||||
_ => None
|
||||
match self.uri {
|
||||
RequestUri::AbsolutePath { path: ref p, .. } => Some(p.as_str()),
|
||||
RequestUri::AbsoluteUri(ref url) => Some(url.path()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// The query string of this Request.
|
||||
#[inline]
|
||||
pub fn query(&self) -> Option<&str> {
|
||||
match self.uri {
|
||||
RequestUri::AbsolutePath { query: ref q, .. } => q.as_ref().map(|x| x.as_str()),
|
||||
RequestUri::AbsoluteUri(ref url) => url.query(),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/// Deconstruct this Request into its pieces.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user