scaffolding out rocket based web service

master
lza_menace 2 years ago
commit 3556b27497

1
.gitignore vendored

@ -0,0 +1 @@
/target

2136
Cargo.lock generated

File diff suppressed because it is too large Load Diff

@ -0,0 +1,11 @@
[package]
name = "nero-explore"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde_json = { version = "1.0" }
rocket = { verion = "=0.5.0-rc.3", features = ["json"] }
rocket_dyn_templates = { version = "=0.1.0-rc.3", features = ["tera"] }

@ -0,0 +1,15 @@
#[macro_use] extern crate rocket;
mod routes;
use routes::block::get_height;
#[get("/")]
fn index() -> &'static str {
"Hello, world!"
}
#[launch]
fn rocket() -> _ {
rocket::build()
.mount("/", routes![index])
.mount("/block", routes![get_height])
}

@ -0,0 +1,12 @@
use rocket::serde::json;
#[get("/height/<block_height>")]
pub fn get_height(block_height: i32) -> json::Value {
return json::json!({
"method": "get_block",
"params": {
"height": block_height
}
});
}

@ -0,0 +1,2 @@
pub mod block;
// pub mod block::get_height;
Loading…
Cancel
Save