1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-25 09:59:21 +02:00

added HttpRequest::query

This commit is contained in:
Nikolay Kim
2017-10-16 09:43:10 -07:00
parent ba1a73443e
commit 88a81155bd
3 changed files with 63 additions and 36 deletions

View File

@ -1,5 +1,6 @@
//! Pieces pertaining to the HTTP message protocol.
use std::{io, str};
use url::form_urlencoded;
use http::{header, Method, Version, Uri, HeaderMap};
use Params;
@ -65,10 +66,18 @@ impl HttpRequest {
self.uri.path()
}
/// The query string of this Request.
/// Return a new iterator that yields pairs of `Cow<str>` for query parameters
#[inline]
pub fn query(&self) -> Option<&str> {
self.uri.query()
pub fn query(&self) -> form_urlencoded::Parse {
form_urlencoded::parse(self.query_string().as_ref())
}
/// The query string in the URL.
///
/// E.g., id=10
#[inline]
pub fn query_string(&self) -> &str {
self.uri.query().unwrap_or("")
}
/// Return request cookies.