#[macro_use] extern crate rocket; use std::net::Ipv4Addr; use rocket::Config; use rocket::serde::json::Json; use easy_sms::telecom; use easy_sms::telecom::Message; #[get("/")] async fn index() -> &'static str { "Hello, world!" } #[post("/send_msg", format="application/json", data="")] async fn send_msg(message: Json>) -> String { let body = telecom::send_msg(message.into_inner()).await.expect("Error"); format!("{}", &body) } #[launch] fn rocket() -> _ { let config = Config { port: 80, address: Ipv4Addr::new(0,0,0,0).into(), ..Config::default() }; rocket::custom(&config) .mount("/", routes![index]) .mount("/", routes![send_msg]) }