✨ From vibe coding to vibe deployment. UBOS MCP turns ideas into infra with one message.

Learn more
Logo

spring-rs is microservice framework written in Rust

English | 中文

crates.io Documentation

spring-rs is a microservice framework written in Rust, similar to SpringBoot in java. spring-rs provides an easily extensible plug-in system for integrating excellent projects in the Rust community, such as axum, sqlx, sea-orm, etc.

Compared with SpringBoot in java, spring-rs has higher performance and lower memory usage, allowing you to completely get rid of the bloated JVM and travel light.

Example

use spring::{get, route, auto_config, App};
use spring_sqlx::{
    sqlx::{self, Row},
    ConnectPool, SqlxPlugin
};
use spring_web::{
    error::Result, extractor::{Path, Component}, handler::TypeRouter, response::IntoResponse, Router,
    WebConfigurator, WebPlugin,
};
use anyhow::Context;

#[auto_config(WebConfigurator)]
#[tokio::main]
async fn main() {
    App::new()
        .add_plugin(SqlxPlugin)
        .add_plugin(WebPlugin)
        .run()
        .await
}

#[get("/")]
async fn hello_world() -> impl IntoResponse {
    "hello world"
}

#[route("/hello/:name", method = "GET", method = "POST")]
async fn hello(Path(name): Path<String>) -> impl IntoResponse {
    format!("hello {name}")
}

#[get("/version")]
async fn sqlx_request_handler(Component(pool): Component<ConnectPool>) -> Result<String> {
    let version = sqlx::query("select version() as version")
        .fetch_one(&pool)
        .await
        .context("sqlx query failed")?
        .get("version");
    Ok(version)
}

Featured Templates

View More
AI Assistants
AI Chatbot Starter Kit v0.1
141 1201
AI Assistants
Image to text with Claude 3
155 1657
AI Image Generation
Image Generation with Stable Diffusion
117 1204
Data Analysis
Pharmacy Admin Panel
254 2271
Customer service
Service ERP
127 1487
AI Characters
Your Speaking Avatar
171 929

Start your free trial

Build your solution today. No credit card required.

Sign In

Register

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.