Expand description
§bora - api Documentation
Hello, and welcome to the bora API documentation!
This API documentation is highly technical and is purely a reference.
Depend on bora in Cargo.toml:
[dependencies]
bora = "0.0.1"Note that development versions, tagged with -dev, are not published
and need to be specified as [git dependencies].
use deboa::errors::DeboaError;
use bora::bora;
use vamo::Vamo;
use serde::Deserialize;
#[derive(Deserialize, Debug)]
pub struct Post {
pub id: u32,
pub title: String,
}
#[bora(
api(
get(name="get_all", path="/posts", res_body=Vec<Post>, format="json"),
get(name="get_by_id", path="/posts/<id:i32>", res_body=Post, format="json"),
get(name="query_by_id", path="/posts?<id:i32>", res_body=Vec<Post>, format="json"),
get(name="query_by_title", path="/posts?<id:i32>&<title:&str>", res_body=Vec<Post>, format="json")
)
)]
pub struct PostService;
#[tokio::main]
async fn main() -> Result<(), DeboaError> {
let client = Vamo::new("https://jsonplaceholder.typicode.com")?;
let mut post_service = PostService::new(client);
let post = post_service.get_by_id(1).await?;
println!("id...: {}", post.id);
println!("title: {}", post.title);
assert_eq!(post.id, 1);
Ok(())
}Disabled features can be selectively enabled in Cargo.toml:
[dependencies]
bora = { version = "0.0.1", features = ["tokio_rt", "http1", "http2"] }
vamo = { version = "0.0.1" }
deboa-extras = { version = "0.0.1" }Attribute Macros§
- bora
- The
boraattribute macro is used to generate a Deboa client. With this macro you can define the API endpoints and their methods. You can define multiple endpoints and methods in the same macro.