Skip to the content.

Vamo Bora

A macro for easy REST client generation on top of the Vamo REST client.

Features

Installation

[dependencies]
vamo-macros = { version = "0.0.5", features = ["json"] }

Basic Example

use deboa::errors::DeboaError;
use vamo::Vamo;
use vamo_macros::bora;

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<()> {
    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(())
}

Features

API Reference

For detailed API documentation, see the docs.rs page.