diff --git a/examples/cookies.rs b/examples/cookies.rs index 1030b78d2..56756c57b 100644 --- a/examples/cookies.rs +++ b/examples/cookies.rs @@ -4,8 +4,8 @@ use tide::{Request, StatusCode}; /// Tide will use the the `Cookies`'s `Extract` implementation to build this parameter. /// -async fn retrieve_cookie(cx: Request<()>) -> tide::Result { - Ok(format!("hello cookies: {:?}", cx.cookie("hello").unwrap())) +async fn retrieve_cookie(req: Request<()>) -> tide::Result { + Ok(format!("hello cookies: {:?}", req.cookie("hello").unwrap())) } async fn insert_cookie(_req: Request<()>) -> tide::Result { diff --git a/examples/graphql.rs b/examples/graphql.rs index f62c3a5d0..42b1fe1f4 100644 --- a/examples/graphql.rs +++ b/examples/graphql.rs @@ -72,14 +72,14 @@ fn create_schema() -> Schema { Schema::new(QueryRoot {}, MutationRoot {}) } -async fn handle_graphql(mut cx: Request) -> tide::Result { - let query: juniper::http::GraphQLRequest = cx +async fn handle_graphql(mut req: Request) -> tide::Result { + let query: juniper::http::GraphQLRequest = req .body_json() .await .expect("be able to deserialize the graphql request"); let schema = create_schema(); // probably worth making the schema a singleton using lazy_static library - let response = query.execute(&schema, cx.state()); + let response = query.execute(&schema, req.state()); let status = if response.is_ok() { StatusCode::Ok } else { diff --git a/src/cookies/middleware.rs b/src/cookies/middleware.rs index f713ae259..8a80cdc5f 100644 --- a/src/cookies/middleware.rs +++ b/src/cookies/middleware.rs @@ -15,7 +15,9 @@ use std::sync::{Arc, RwLock}; /// # use tide::{Request, Response, StatusCode}; /// # use tide::http::cookies::Cookie; /// let mut app = tide::Server::new(); -/// app.at("/get").get(|cx: Request<()>| async move { Ok(cx.cookie("testCookie").unwrap().value().to_string()) }); +/// app.at("/get").get(|req: Request<()>| async move { +/// Ok(req.cookie("testCookie").unwrap().value().to_string()) +/// }); /// app.at("/set").get(|_| async { /// let mut res = Response::new(StatusCode::Ok); /// res.insert_cookie(Cookie::new("testCookie", "NewCookieValue")); diff --git a/src/router.rs b/src/router.rs index e210c82aa..701dbbdf1 100644 --- a/src/router.rs +++ b/src/router.rs @@ -82,10 +82,10 @@ impl Router { } } -fn not_found_endpoint(_cx: Request) -> BoxFuture<'static, crate::Result> { +fn not_found_endpoint(_req: Request) -> BoxFuture<'static, crate::Result> { Box::pin(async move { Ok(Response::new(StatusCode::NotFound)) }) } -fn method_not_allowed(_cx: Request) -> BoxFuture<'static, crate::Result> { +fn method_not_allowed(_req: Request) -> BoxFuture<'static, crate::Result> { Box::pin(async move { Ok(Response::new(StatusCode::MethodNotAllowed)) }) } diff --git a/tests/cookies.rs b/tests/cookies.rs index 3af203e4f..3eed212e2 100644 --- a/tests/cookies.rs +++ b/tests/cookies.rs @@ -6,11 +6,11 @@ use tide::{Request, Response, Server, StatusCode}; static COOKIE_NAME: &str = "testCookie"; -async fn retrieve_cookie(cx: Request<()>) -> tide::Result { +async fn retrieve_cookie(req: Request<()>) -> tide::Result { Ok(format!( "{} and also {}", - cx.cookie(COOKIE_NAME).unwrap().value(), - cx.cookie("secondTestCookie").unwrap().value() + req.cookie(COOKIE_NAME).unwrap().value(), + req.cookie("secondTestCookie").unwrap().value() )) } diff --git a/tests/wildcard.rs b/tests/wildcard.rs index 9adabc605..64d2edd33 100644 --- a/tests/wildcard.rs +++ b/tests/wildcard.rs @@ -1,32 +1,32 @@ use http_types::{Method, StatusCode, Url}; use tide::{http, Request}; -async fn add_one(cx: Request<()>) -> Result { - match cx.param::("num") { +async fn add_one(req: Request<()>) -> Result { + match req.param::("num") { Ok(num) => Ok((num + 1).to_string()), Err(err) => Err(tide::Error::new(StatusCode::BadRequest, err)), } } -async fn add_two(cx: Request<()>) -> Result { - let one = cx +async fn add_two(req: Request<()>) -> Result { + let one = req .param::("one") .map_err(|err| tide::Error::new(StatusCode::BadRequest, err))?; - let two = cx + let two = req .param::("two") .map_err(|err| tide::Error::new(StatusCode::BadRequest, err))?; Ok((one + two).to_string()) } -async fn echo_path(cx: Request<()>) -> Result { - match cx.param::("path") { +async fn echo_path(req: Request<()>) -> Result { + match req.param::("path") { Ok(path) => Ok(path), Err(err) => Err(tide::Error::new(StatusCode::BadRequest, err)), } } -async fn echo_empty(cx: Request<()>) -> Result { - match cx.param::("") { +async fn echo_empty(req: Request<()>) -> Result { + match req.param::("") { Ok(path) => Ok(path), Err(err) => Err(tide::Error::new(StatusCode::BadRequest, err)), }