[][src]Crate tide

Serve the web

Tide is a friendly HTTP server built for casual Rustaceans and veterans alike. It's completely modular, and built directly for async/await. Whether it's a quick webhook, or an L7 load balancer, Tide will make it work.

Examples

hello world

let mut app = tide::new();
app.at("/").get(|_| async move { "Hello, world!" });
app.listen("127.0.0.1:8080").await?;

echo server

let mut app = tide::new();
app.at("/").get(|req| async move { req });
app.listen("127.0.0.1:8080").await?;

send and receive json note: this example doesn't compile yet because we still need to work on our error handling. Replace ? with .unwrap() if you want to make this compile

This example is not tested
#[derive(Debug, Deserialize, Serialize)]
struct Counter { count: usize }

let mut app = tide::new();
app.at("/").get(|mut req: tide::Request<()>| async move {
   let mut counter: Counter = req.body_json().await?;
   println!("count is {}", counter.count);
   counter.count += 1;
   tide::Response::new(200).body_json(&counter)?
});
app.listen("127.0.0.1:8080").await?;

Stability

It's still early in Tide's development cycle. While the general shape of Tide might have roughly established, the exact traits and function paramaters may change between versions. In practice this means that building your core business on Tide is probably not a wise idea... yet.

However we are committed to closely following semver, and documenting any and all breaking changes we make. Also as time goes on you may find that fewer and fewer changes occur, until we eventually remove this notice entirely.

The goal of Tide is to build a premier HTTP experience for Async Rust. We have a long journey ahead of us. But we're excited you're here with us!

Re-exports

pub use http;

Modules

prelude

The Tide prelude.

server

An HTTP server

Structs

Error

A generic error.

Next

The remainder of a middleware chain, including the endpoint.

Request

An HTTP request.

Response

An HTTP response

Route

A handle to a route.

Server

An HTTP server.

Traits

Endpoint

An HTTP request handler.

IntoResponse

Conversion into a Response.

Middleware

Middleware that wraps around remaining middleware chain.

ResultExt

Extension methods for Result.

Functions

new

Create a new Tide server.

redirect

Redirect a route to another route.

with_state

Create a new Tide server with shared global state.

Type Definitions

Result

A specialized Result type for Tide.