CoreX
CoreX is a modular API framework for building extensible systems in Rust. It allows you to create a core system and extend its functionality through plugins (extensions). This crate is designed to be simple, flexible, and easy to use, making it ideal for building modular web applications.
Features
- Modular Design: Extend the core system with plugins (extensions).
- Easy to Use: Simple API for registering extensions and running the server.
- Asynchronous: Built on top of
axum
andtokio
for high-performance asynchronous operations. - Extensible: Add custom routes, middleware, and functionality through extensions.
Installation
Add corex
to your Cargo.toml
:
[]
= "0.1.0"
Usage
1. Define an Extension
Create an extension by implementing the ExtensionTrait
:
use ;
use json;
use ;
use Arc;
;
2. Register Extensions and Run the Server
Use the Core
system to register extensions and start the server:
async
3. Test the Endpoints
Start the server and test the endpoints:
Response:
Example: Multiple Extensions
You can register multiple extensions to extend the core system:
;
async
Test the endpoints:
API Documentation
Core
new(host: String, port: u16)
: Creates a new Core system.register_extension(extension: Arc<dyn ExtensionTrait>)
: Registers an extension.build() -> Router
: Builds the final router by applying all registered extensions.run()
: Starts the server and listens for incoming requests.
ExtensionTrait
name() -> &'static str
: Returns the name of the extension.extend(router: Router) -> Router
: Extends the router with additional routes or middleware.
Running Tests
To run the tests, use the following command:
Contributing
Contributions are welcome! If you'd like to contribute, please:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Submit a pull request.
License
This project is licensed under:
- MIT License (LICENSE-MIT)
Acknowledgments
Questions?
If you have any questions or need help, feel free to open an issue or reach out to the maintainers.