Crates.io | resty |
lib.rs | resty |
version | 0.1.0 |
source | src |
created_at | 2017-09-11 23:42:29.180427 |
updated_at | 2017-09-11 23:42:29.180427 |
description | A simple JSON REST-API framework. |
homepage | https://github.com/tomusdrw/resty |
repository | https://github.com/tomusdrw/resty |
max_upload_size | |
id | 31448 |
size | 42,730 |
Resty - a simple JSON REST-API framework for Rust.
extern crate futures;
extern crate resty;
#[macro_use]
extern crate serde_derive;
use futures::Future;
#[derive(Deserialize, Serialize)]
struct Call {
pub test: u64,
}
fn main() {
let mut server = resty::Router::new();
server.get("/", |_| {
Ok("Hello World!")
});
server.post("/call", |request| {
// Deserialize payload
request.json().map(|mut call: Call| {
call.test += 1;
// And return the same payload as a response
call
})
});
let listening = server.bind("localhost:3000").unwrap();
listening.wait()
}
For more see examples folder.
get_*()
for dynamic params.Into<Router>
for structs.