Skip to content

Commit c60c37b

Browse files
committed
Rename Request::uri to Request::url
1 parent 10fa9ea commit c60c37b

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

src/fs/serve_dir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl ServeDir {
2222

2323
impl<State> Endpoint<State> for ServeDir {
2424
fn call<'a>(&'a self, req: Request<State>) -> BoxFuture<'a, Result> {
25-
let path = req.uri().path();
25+
let path = req.url().path();
2626
let path = path.trim_start_matches(&self.prefix);
2727
let path = path.trim_start_matches('/');
2828
let mut file_path = self.dir.clone();

src/log/middleware.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl LogMiddleware {
3030
ctx: Request<State>,
3131
next: Next<'a, State>,
3232
) -> crate::Result {
33-
let path = ctx.uri().path().to_owned();
33+
let path = ctx.url().path().to_owned();
3434
let method = ctx.method().to_string();
3535
log::info!("<-- Request received", {
3636
method: method,

src/request.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub struct Request<State> {
2929
}
3030

3131
impl<State> Request<State> {
32+
/// Create a new `Request`.
3233
pub(crate) fn new(
3334
state: Arc<State>,
3435
req: http_types::Request,
@@ -77,15 +78,15 @@ impl<State> Request<State> {
7778
///
7879
/// let mut app = tide::new();
7980
/// app.at("/").get(|req: Request<()>| async move {
80-
/// assert_eq!(req.uri(), &"/".parse::<tide::http::Url>().unwrap());
81+
/// assert_eq!(req.url(), &"/".parse::<tide::http::Url>().unwrap());
8182
/// Ok("")
8283
/// });
8384
/// app.listen("127.0.0.1:8080").await?;
8485
/// #
8586
/// # Ok(()) })}
8687
/// ```
8788
#[must_use]
88-
pub fn uri(&self) -> &Url {
89+
pub fn url(&self) -> &Url {
8990
self.req.url()
9091
}
9192

@@ -269,7 +270,7 @@ impl<State> Request<State> {
269270
// Default to an empty query string if no query parameter has been specified.
270271
// This allows successful deserialisation of structs where all fields are optional
271272
// when none of those fields has actually been passed by the caller.
272-
let query = self.uri().query().unwrap_or("");
273+
let query = self.url().query().unwrap_or("");
273274
serde_qs::from_str(query).map_err(|e| {
274275
// Return the displayable version of the deserialisation error to the caller
275276
// for easier debugging.

tests/nested.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ async fn nested() {
3434

3535
#[async_std::test]
3636
async fn nested_middleware() {
37-
let echo_path = |req: tide::Request<()>| async move { Ok(req.uri().path().to_string()) };
37+
let echo_path = |req: tide::Request<()>| async move { Ok(req.url().path().to_string()) };
3838

3939
#[derive(Debug, Clone, Default)]
4040
pub struct TestMiddleware;

tests/route_middleware.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl<State: Send + Sync + 'static> Middleware<State> for TestMiddleware {
3030
}
3131

3232
async fn echo_path<State>(req: tide::Request<State>) -> tide::Result<String> {
33-
Ok(req.uri().path().to_string())
33+
Ok(req.url().path().to_string())
3434
}
3535

3636
#[async_std::test]

0 commit comments

Comments
 (0)