Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benches/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn criterion_benchmark(c: &mut Criterion) {
router.add(
"hello",
Method::Get,
Box::new(|_| async move { Ok("hello world") }),
Box::new(|_| async { Ok("hello world") }),
);

c.bench_function("route-match", |b| {
Expand Down
2 changes: 1 addition & 1 deletion examples/chunked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use tide::{Body, Response, StatusCode};
fn main() -> Result<(), std::io::Error> {
task::block_on(async {
let mut app = tide::new();
app.at("/").get(|_| async move {
app.at("/").get(|_| async {
let mut res = Response::new(StatusCode::Ok);
res.set_body(Body::from_file(file!()).await.unwrap());
Ok(res)
Expand Down
2 changes: 1 addition & 1 deletion examples/hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
async fn main() -> Result<(), std::io::Error> {
tide::log::start();
let mut app = tide::new();
app.at("/").get(|_| async move { Ok("Hello, world!") });
app.at("/").get(|_| async { Ok("Hello, world!") });
app.listen("127.0.0.1:8080").await?;
Ok(())
}
7 changes: 3 additions & 4 deletions examples/nested.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#[async_std::main]
async fn main() -> Result<(), std::io::Error> {
let mut app = tide::new();
app.at("/").get(|_| async move { Ok("Root") });
app.at("/").get(|_| async { Ok("Root") });
app.at("/api").nest({
let mut api = tide::new();
api.at("/hello").get(|_| async move { Ok("Hello, world") });
api.at("/goodbye")
.get(|_| async move { Ok("Goodbye, world") });
api.at("/hello").get(|_| async { Ok("Hello, world") });
api.at("/goodbye").get(|_| async { Ok("Goodbye, world") });
api
});
app.listen("127.0.0.1:8080").await?;
Expand Down
4 changes: 2 additions & 2 deletions examples/redirect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use tide::{http::StatusCode, Redirect, Response};
#[async_std::main]
async fn main() -> Result<(), std::io::Error> {
let mut app = tide::new();
app.at("/").get(|_| async move { Ok("Root") });
app.at("/").get(|_| async { Ok("Root") });

// Redirect hackers to YouTube.
app.at("/.env")
.get(Redirect::new("https://www.youtube.com/watch?v=dQw4w9WgXcQ"));

app.at("/users-page").get(|_| async move {
app.at("/users-page").get(|_| async {
Ok(if signed_in() {
Response::new(StatusCode::Ok)
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
//! # fn main() -> Result<(), std::io::Error> { block_on(async {
//! #
//! let mut app = tide::new();
//! app.at("/").get(|_| async move { Ok("Hello, world!") });
//! app.at("/").get(|_| async { Ok("Hello, world!") });
//! app.listen("127.0.0.1:8080").await?;
//! #
//! # Ok(()) }) }
Expand All @@ -41,7 +41,7 @@
//! # fn main() -> Result<(), std::io::Error> { block_on(async {
//! #
//! let mut app = tide::new();
//! app.at("/").get(|req| async move { Ok(req) });
//! app.at("/").get(|req| async { Ok(req) });
//! app.listen("127.0.0.1:8080").await?;
//! #
//! # Ok(()) }) }
Expand Down Expand Up @@ -233,7 +233,7 @@ pub use http_types::{self as http, Body, Error, Status, StatusCode};
/// # fn main() -> Result<(), std::io::Error> { block_on(async {
/// #
/// let mut app = tide::new();
/// app.at("/").get(|_| async move { Ok("Hello, world!") });
/// app.at("/").get(|_| async { Ok("Hello, world!") });
/// app.listen("127.0.0.1:8080").await?;
/// #
/// # Ok(()) }) }
Expand Down
2 changes: 1 addition & 1 deletion src/redirect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//! use tide::Redirect;
//!
//! let mut app = tide::new();
//! app.at("/").get(|_| async move { Ok("meow") });
//! app.at("/").get(|_| async { Ok("meow") });
//! app.at("/nori").get(Redirect::temporary("/"));
//! app.listen("127.0.0.1:8080").await?;
//! #
Expand Down
4 changes: 2 additions & 2 deletions src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ impl<State: 'static> Router<State> {
}

fn not_found_endpoint<State>(_req: Request<State>) -> BoxFuture<'static, crate::Result> {
Box::pin(async move { Ok(Response::new(StatusCode::NotFound)) })
Box::pin(async { Ok(Response::new(StatusCode::NotFound)) })
}

fn method_not_allowed<State>(_req: Request<State>) -> BoxFuture<'static, crate::Result> {
Box::pin(async move { Ok(Response::new(StatusCode::MethodNotAllowed)) })
Box::pin(async { Ok(Response::new(StatusCode::MethodNotAllowed)) })
}
2 changes: 1 addition & 1 deletion src/security/cors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ mod test {

fn app() -> crate::Server<()> {
let mut app = crate::Server::new();
app.at(ENDPOINT).get(|_| async move { Ok("Hello World") });
app.at(ENDPOINT).get(|_| async { Ok("Hello World") });

app
}
Expand Down
6 changes: 3 additions & 3 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl Server<()> {
/// # fn main() -> Result<(), std::io::Error> { block_on(async {
/// #
/// let mut app = tide::new();
/// app.at("/").get(|_| async move { Ok("Hello, world!") });
/// app.at("/").get(|_| async { Ok("Hello, world!") });
/// app.listen("127.0.0.1:8080").await?;
/// #
/// # Ok(()) }) }
Expand Down Expand Up @@ -213,7 +213,7 @@ impl<State: Send + Sync + 'static> Server<State> {
///
/// ```rust,no_run
/// # let mut app = tide::Server::new();
/// app.at("/").get(|_| async move { Ok("Hello, world!") });
/// app.at("/").get(|_| async { Ok("Hello, world!") });
/// ```
///
/// A path is comprised of zero or many segments, i.e. non-empty strings
Expand Down Expand Up @@ -369,7 +369,7 @@ impl<State: Send + Sync + 'static> Server<State> {
/// use tide::http::{Url, Method, Request, Response};
///
/// let mut app = tide::new();
/// app.at("/").get(|_| async move { Ok("hello world") });
/// app.at("/").get(|_| async { Ok("hello world") });
///
/// let req = Request::new(Method::Get, Url::parse("https://example.com")?);
/// let res: Response = app.respond(req).await?;
Expand Down
2 changes: 1 addition & 1 deletion tests/chunked-encode-small.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async fn chunked_large() -> Result<(), http_types::Error> {
let port = test_utils::find_port().await;
let server = task::spawn(async move {
let mut app = tide::new();
app.at("/").get(|_| async move {
app.at("/").get(|_| async {
let mut res = Response::new(StatusCode::Ok);
let body = Cursor::new(TEXT.to_owned());
res.set_body(Body::from_reader(body, None));
Expand Down
2 changes: 1 addition & 1 deletion tests/nested.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async fn nested_with_different_state() {
let num = req.state();
Ok(format!("the number is {}", num))
});
outer.at("/").get(|_| async move { Ok("Hello, world!") });
outer.at("/").get(|_| async { Ok("Hello, world!") });
outer.at("/foo").nest(inner);

let req = Request::new(Method::Get, Url::parse("http://example.com/foo").unwrap());
Expand Down
2 changes: 1 addition & 1 deletion tests/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async fn json_content_type() {
use tide::Body;

let mut app = tide::new();
app.at("/json_content_type").get(|_| async move {
app.at("/json_content_type").get(|_| async {
let mut map = BTreeMap::new();
map.insert(Some("a"), 2);
map.insert(Some("b"), 4);
Expand Down
2 changes: 1 addition & 1 deletion tests/wildcard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ async fn invalid_wildcard() {
#[async_std::test]
async fn nameless_wildcard() {
let mut app = tide::Server::new();
app.at("/echo/:").get(|_| async move { Ok("") });
app.at("/echo/:").get(|_| async { Ok("") });

let req = http::Request::new(
Method::Get,
Expand Down