Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nuriofernandez/rust-experiment-http-api-tokio-warp

Experimental project to test Rust language and with 'warp' and 'tokio' libraries
https://github.com/nuriofernandez/rust-experiment-http-api-tokio-warp

example-project experiment rust-lang tokio-rs warp

Last synced: 2 days ago
JSON representation

Experimental project to test Rust language and with 'warp' and 'tokio' libraries

Awesome Lists containing this project

README

        

# Rust experimental HTTP API

Experimental project to test the Rust language and the 'warp' and 'tokio' libraries

```rust
// GET / => 200 OK with body "It works!"
let default = warp::path::end().map(|| "It works!");

// GET /hello/warp => 200 OK with body "Hello, warp!"
let hello = warp::path!("hello" / String)
.map(|name| format!("Hello, {}!", name));

// GET /bye/nurio => 200 OK with body "Bye, nurio!"
let bye = warp::path!("bye" / String)
.map(|name| format!("Bye, {}!", name));

// Map filters
let routes = default.or(hello).or(bye);

// Start the http server
warp::serve(routes)
.run(([127, 0, 0, 1], 3030))
.await;
```