Start backend with rocket.rs

This commit is contained in:
2021-08-15 12:07:02 +02:00
parent cb44ae4184
commit 28011b8f93
5 changed files with 1440 additions and 0 deletions

20
rs/src/main.rs Normal file
View File

@@ -0,0 +1,20 @@
#[macro_use]
extern crate rocket;
use rocket::serde::{json::Json, Serialize};
#[derive(Serialize)]
struct Greeting<'a> {
hello: &'a str,
}
#[get("/")]
fn index() -> Json<Greeting<'static>> {
Json(Greeting {
hello: "Hello, world!",
})
}
#[launch]
fn rocket() -> _ {
rocket::build().mount("/api/", routes![index])
}