mirror of
https://github.com/docker/awesome-compose.git
synced 2025-04-26 02:38:07 +02:00
react-rust-postgres: create simple server
Signed-off-by: Jérémie Drouet <jeremie.drouet@gmail.com>
This commit is contained in:
parent
4478c5c142
commit
bdd0256bfc
6 changed files with 91 additions and 0 deletions
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();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue