Crates.io | vine |
lib.rs | vine |
version | 0.1.4 |
source | src |
created_at | 2024-08-02 07:25:01.464361 |
updated_at | 2024-10-28 10:54:57.154668 |
description | Vine is rust framework inspired by Spring Boot |
homepage | |
repository | |
max_upload_size | |
id | 1322897 |
size | 3,151 |
Vine is rust framework inspired by Spring Boot
Example:
use std::sync::Arc;
use async_trait::async_trait;
use axum::extract::Path;
use axum::response::IntoResponse;
use vine::{Bean, controller, get, injectable};
use vine::vine_core::core::Error;
#[async_trait]
trait Service {
async fn compute(&self, name: String) -> String;
}
#[derive(Bean)]
struct Controller {
service: Arc<dyn Service + Sync + Send>,
}
#[controller]
impl Controller {
#[get("/hello/:name")]
async fn say_hello(&self, Path(name): Path<String>) -> impl IntoResponse {
self.service.compute(name).await
}
}
#[derive(Bean)]
struct ServiceImpl {
#[value("${service.name:DefaultName}")] name: String,
}
#[async_trait]
#[injectable]
impl Service for ServiceImpl {
async fn compute(&self, name: String) -> String {
format!("Hello from the {}: {}", &self.name, name)
}
}
#[tokio::main]
async fn main() -> Result<(), Error> {
vine::create_app()?
.exec().await
}