Skip to content

noble-gase/rn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

氡-Rn

crates.io MIT

[氡-Rn] Rust Web开发脚手架,支持 salvoaxum 框架,并同时支持创建「单应用」和「多应用」

安装

cargo install rnx

特点

  • DB使用 sqlx
  • Redis使用 redis-rs
  • 日志使用 tracing
  • 配置使用 config-rs
  • 命令行使用 clap
  • 异步运行时使用 tokio
  • 参数验证器使用 validator
  • 支持 Prometheus Metrics 和 Request 中间件
  • 包含 TraceId、认证、请求日志、Panic捕获 中间件
  • 简单好用的 API Result(宏定义错误码)统一输出方式

创建项目

Salvo

单应用
rnx new # 在当前目录初始化项目
rnx new --name demo # 创建demo项目
.
├── src
│   ├── app
│   │   ├── cmd
│   │   ├── hanlder
│   │   ├── middleware
│   │   ├── router
│   │   ├── service
│   │   └── main.rs
│   └── shared
│       ├── core
│       ├── middleware
│       ├── result
│       ├── util
│       └── lib.rs
├── Cargo.toml
├── Dockerfile
└── config.toml
多应用
rnx new --app foo --app bar # 在当前目录初始化项目
rnx new --name demo --app foo --app bar # 创建demo项目
.
├── src
│   ├── app
│   │   ├── foo
│   │   │   ├── cmd
│   │   │   ├── handler
│   │   │   ├── middleware
│   │   │   ├── router
│   │   │   ├── service
│   │   │   └── main.rs
│   │   └── bar
│   │       ├── ...
│   │       └── main.rs
│   └── shared
│       ├── core
│       ├── middleware
│       ├── result
│       ├── util
│       └── lib.rs
├── Cargo.toml
├── foo.dockerfile
├── bar.dockerfile
├── foo.config.toml
└── bar.config.toml

Axum

单应用
rnx new --axum # 在当前目录初始化项目
rnx new --name demo --axum # 创建demo项目
.
├── src
│   ├── app
│   │   ├── cmd
│   │   ├── hanlder
│   │   ├── middleware
│   │   ├── router
│   │   ├── service
│   │   └── main.rs
│   └── shared
│       ├── core
│       ├── middleware
│       ├── result
│       ├── util
│       └── lib.rs
├── Cargo.toml
├── Dockerfile
└── config.toml
多应用
rnx new --app foo --app bar --axum # 在当前目录初始化项目
rnx new --name demo --app foo --app bar --axum # 创建demo项目
.
├── src
│   ├── app
│   │   ├── foo
│   │   │   ├── cmd
│   │   │   ├── handler
│   │   │   ├── middleware
│   │   │   ├── router
│   │   │   ├── service
│   │   │   └── main.rs
│   │   └── bar
│   │       ├── ...
│   │       └── main.rs
│   └── shared
│       ├── core
│       ├── middleware
│       ├── result
│       ├── util
│       └── lib.rs
├── Cargo.toml
├── foo.dockerfile
├── bar.dockerfile
├── foo.config.toml
└── bar.config.toml

创建应用

多应用项目适用,需在项目根目录执行(即:Cargo.toml 所在目录)

Salvo

rnx app --name foo --name bar
.
├── src
│   ├── app
│   │   ├── foo
│   │   │   ├── cmd
│   │   │   ├── handler
│   │   │   ├── middleware
│   │   │   ├── router
│   │   │   ├── service
│   │   │   └── main.rs
│   │   └── bar
│   │       ├── ...
│   │       └── main.rs
│   └── shared
├── Cargo.toml
├── foo.dockerfile
├── bar.dockerfile
├── foo.config.toml
└── bar.config.toml

Axum

rnx app --name foo --name bar --axum
.
├── src
│   ├── app
│   │   ├── foo
│   │   │   ├── cmd
│   │   │   ├── handler
│   │   │   ├── middleware
│   │   │   ├── router
│   │   │   ├── service
│   │   │   └── main.rs
│   │   └── bar
│   │       ├── ...
│   │       └── main.rs
│   └── shared
├── Cargo.toml
├── foo.dockerfile
├── bar.dockerfile
├── foo.config.toml
└── bar.config.toml

Enjoy 😊

About

[氡-Rn] Rust Web开发脚手架「Salvo & Axum」

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •