Skip to content

Commit

Permalink
changelog
Browse files Browse the repository at this point in the history
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
  • Loading branch information
yoshuawuyts committed Nov 27, 2019
1 parent c444900 commit da91781
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
30 changes: 21 additions & 9 deletions CHANGELOG.md
Expand Up @@ -24,16 +24,27 @@ easier to write APIs with Tide out of the box.

## Example

Create a "hello world" app:
```rust
use async_std::task;

fn main() -> Result<(), std::io::Error> {
task::block_on(async {
let mut app = tide::new();
app.at("/").get(|_| async move { "Hello, world!" });
app.listen("127.0.0.1:8080").await?;
Ok(())
})
#[async_std::main]
async fn main() -> Result<(), std::io::Error> {
let mut app = tide::new();
app.at("/").get(|_| async move { "Hello, world!" });
app.listen("127.0.0.1:8080").await?;
Ok(())
}
```

Redirect from `/nori` to `/chashu`:

```rust
#[async_std::main]
async fn main() -> Result<(), std::io::Error> {
let mut app = tide::new();
app.at("/chashu").get(|_| async move { "meow" });
app.at("/nori").get(tide::redirect("/chashu"));
app.listen("127.0.0.1:8080").await?;
Ok(())
}
```

Expand All @@ -47,6 +58,7 @@ fn main() -> Result<(), std::io::Error> {
- Added a `new` free function, a shorthand for `Server::new`.
- Added a `with_state` free function, a shorthand for `Server::with_state`.
- Added `Result` type alias (replaces `EndpointResult`).
- Added a `redirect` free function to redirect from one endpoint to another.

### Changed

Expand Down
5 changes: 2 additions & 3 deletions src/redirect.rs
@@ -1,9 +1,9 @@
use async_std::task::{Context, Poll};
use async_std::future;
use async_std::task::{Context, Poll};

use std::pin::Pin;

use crate::{Request, Response, Endpoint};
use crate::{Endpoint, Request, Response};

/// Redirect a route to another route.
///
Expand Down Expand Up @@ -52,4 +52,3 @@ impl future::Future for Future {
Poll::Ready(self.res.take().unwrap())
}
}

0 comments on commit da91781

Please sign in to comment.