mirror of
https://github.com/guilhermewerner/rust-api
synced 2025-06-15 14:35:15 +00:00
32 lines
547 B
Rust
32 lines
547 B
Rust
#![feature(proc_macro_hygiene, decl_macro)]
|
|
|
|
#[macro_use]
|
|
extern crate rocket;
|
|
|
|
#[macro_use]
|
|
extern crate rocket_contrib;
|
|
|
|
use rocket_contrib::json::{Json, JsonValue};
|
|
|
|
#[get("/")]
|
|
fn hello() -> JsonValue {
|
|
return json!({ "TribuFu": "Hello World" });
|
|
}
|
|
|
|
#[catch(404)]
|
|
fn not_found() -> JsonValue {
|
|
return json!({
|
|
"Error": "RESOURCE_NOT_FOUND"
|
|
});
|
|
}
|
|
|
|
fn rocket() -> rocket::Rocket {
|
|
return rocket::ignite()
|
|
.mount("/", routes![hello])
|
|
.register(catchers![not_found]);
|
|
}
|
|
|
|
fn main() {
|
|
rocket().launch();
|
|
}
|