nano-rs is a lightweight, non-invasive, convention-over-configuration Rust Web service component, aimed at providing a fast and efficient development experience. By reducing the burden of configuration, it allows you to focus more on implementing business logic.
- Lightweight: Ensures fast startup and low resource consumption through a streamlined design.
- Non-invasive: The framework's design allows for seamless integration into existing Rust projects without fear of interfering with business logic.
- Convention Over Configuration: The framework adopts an "intelligent defaults" approach, providing pre-set configurations for common scenarios. This means you can get started with little to no configuration, yet it still offers ample configuration options to suit specific needs ensuring ultimate flexibility and extensibility.
- Business Focused: Our goal is to simplify the development process of Web services. By reducing the tedious and miscellaneous configuration tasks, you can concentrate more on implementing the business logic, thus improving the efficiency and quality of project development.
Environment Requirements
MSRV >= 1.66
Installation
cargo add nano-rs
Quick Start
Axum
- Add build dependencies
[]
= "0.1.0"
= "0.1.0"
- Add build.rs
use Error;
use NanoBuilder;
use AxumGenRoute;
- Add the configuration file to your desired directory (in the example, it is placed in etc/config.yaml)
port: 8888
name: example
host: 127.0.0.1
- Write your API code anywhere in project with marco (for example, under api/pet), for macros, please refer to example (documentation coming soon...)
pub async
- Run build once (only needed for the project's first compilation)
cargo build
- Then you will get file named
routes.rsin yoursrc/. - Do not edit
routes.rsas it will be overwritten every time you build. - Edit
main.rs. (refer to the project structure in the example)
use Router;
use run;
use init_config_with_cli;
use RestConfig;
use crateget_routes;
async
- Run your web application
cargo run -- --config etc/config.yaml
- After this, you only need to focus on writing your business logic code; nano-rs will automatically generate routes and register them with axum, allowing you to concentrate solely on implementing business logic.
Roadmap
- Auto-generate Axum framework routes
- Default configuration for Tracing framework
- Preset common web service configuration (managed via yaml)
- Auto-generate OpenApi
For a full list of proposed features (and known issues), please see the open issues.
License
Distributed under the MIT License. For more information, see LICENSE.txt.