mirror of https://github.com/rwf2/Rocket.git
Make the `uri` parameter in Request private.
This commit is contained in:
parent
f3b23b01d6
commit
650d079b58
|
@ -12,7 +12,7 @@ fn hello(name: &str, age: i8) -> String {
|
|||
fn not_found(req: &rocket::Request) -> String {
|
||||
format!("<p>Sorry, but '{}' is not a valid path!</p>
|
||||
<p>Try visiting /hello/<name>/<age> instead.</p>",
|
||||
req.uri)
|
||||
req.uri())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -132,8 +132,8 @@ impl<'a> From<&'a str> for URIBuf {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Collider for URI<'a> {
|
||||
fn collides_with(&self, other: &URI) -> bool {
|
||||
impl<'a, 'b> Collider<URI<'b>> for URI<'a> {
|
||||
fn collides_with(&self, other: &URI<'b>) -> bool {
|
||||
let mut trailing = false;
|
||||
for (seg_a, seg_b) in self.segments().zip(other.segments()) {
|
||||
if seg_a.ends_with("..>") || seg_b.ends_with("..>") {
|
||||
|
|
|
@ -23,8 +23,6 @@ use http::{Method, ContentType, Cookies};
|
|||
pub struct Request<'a> {
|
||||
/// The HTTP method associated with the request.
|
||||
pub method: Method,
|
||||
/// The URI associated with the request.
|
||||
pub uri: URIBuf, // FIXME: Should be URI (without Hyper).
|
||||
/// <div class="stability" style="margin-left: 0;">
|
||||
/// <em class="stab unstable">
|
||||
/// Unstable
|
||||
|
@ -35,9 +33,12 @@ pub struct Request<'a> {
|
|||
///
|
||||
/// The data in the request.
|
||||
pub data: Vec<u8>, // FIXME: Don't read this! (bad Hyper.)
|
||||
uri: URIBuf, // FIXME: Should be URI (without Hyper).
|
||||
cookies: Cookies,
|
||||
headers: HyperHeaders, // This sucks.
|
||||
params: RefCell<Option<Vec<&'a str>>>, // This also sucks.
|
||||
/// Indexes into the URI.
|
||||
// params: RefCell<Vec<(usize, usize)>>,
|
||||
params: RefCell<Option<Vec<&'a str>>>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
|
@ -157,7 +158,7 @@ impl<'a> Request<'a> {
|
|||
|
||||
/// Retrieves the URI from the request. Rocket only allows absolute URIs, so
|
||||
/// the URI will be absolute.
|
||||
pub fn uri(&'a self) -> URI<'a> {
|
||||
pub fn uri(&self) -> URI {
|
||||
self.uri.as_uri()
|
||||
}
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ impl Collider for Route {
|
|||
impl<'r> Collider<Request<'r>> for Route {
|
||||
fn collides_with(&self, req: &Request) -> bool {
|
||||
self.method == req.method
|
||||
&& req.uri.as_uri().collides_with(&self.path.as_uri())
|
||||
&& req.uri().collides_with(&self.path.as_uri())
|
||||
&& req.accepts().collides_with(&self.content_type)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue