react-rust-postgres: create simple server
Signed-off-by: Jérémie Drouet <jeremie.drouet@gmail.com>
This commit is contained in:
25
react-rust-postgres/backend/src/main.rs
Normal file
25
react-rust-postgres/backend/src/main.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
#![feature(proc_macro_hygiene, decl_macro)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate rocket;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
extern crate rocket_contrib;
|
||||
|
||||
use rocket_contrib::json::Json;
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct HelloMessage {
|
||||
message: String,
|
||||
}
|
||||
|
||||
#[get("/")]
|
||||
fn index() -> Json<HelloMessage> {
|
||||
Json(HelloMessage {
|
||||
message: String::from("Hello, world"),
|
||||
})
|
||||
}
|
||||
|
||||
fn main() {
|
||||
rocket::ignite().mount("/", routes![index]).launch();
|
||||
}
|
Reference in New Issue
Block a user