REST APIs with Rocket for RUST
Excerpts of code snippets to write rust based rest service using the rocket framework.
Add dependencies #[macro_use] extern crate rocket; extern crate rocket_contrib; extern crate serde_json; extern crate log; Start Server fn main() { rocket::ignite().mount("/", routes![index, send]).launch(); } Get (Hello World Example) #[get("/")] fn index() -> &'static str { "Hello, world!" } Try it out curl http://localhost:15188/ POST with untyped object #[post("/send", format = "application/json", data ="<data>")] fn send(data: String) -> std::io::Result<String> { let data: Value = serde_json::from_str(&data)?