Start backend with rocket.rs
This commit is contained in:
20
rs/src/main.rs
Normal file
20
rs/src/main.rs
Normal 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])
|
||||
}
|
||||
Reference in New Issue
Block a user