Swim ⚡🏊
An opinionated batteries-included approach to a rust web framework.
The idea is to take the best parts of the rust ecosystem and combine them into a framework that is easy to use and provides a good developer experience.
Installation
Add the following to your Cargo.toml file.
[]
= "0.2"
Features
- Go blazingly fast with hyper and tokio
- Powerful routing with routerify
- CLI tooling with cargo-swim (coming soon)
- Database support with SeaORM (planned)
- Templating with Tera (planned)
- Dependency injection (planned)
Building a project
You define a project by defining a struct that implements the Project trait. It is the highest-level abstraction in the framework. It is responsible for defining the settings, apps, and middleware for your project.
use *;
;
Building apps
You define an app by defining a struct that implements the App trait. It is responsible for defining the routes and views for your app.
use *;
;
Building views
You define a view by defining a struct that implements the View trait. It is responsible for handling the request and returning a response. You can implement the specific HTTP methods you want to handle.
;
Defining middlewares
You define a middleware by defining a struct that implements the Middleware trait. You may hook into the pre and post methods which are capable of modifying the upcoming request and leaving response respectively (or you could simply use these for monitoring traffic).
;
Running the project
You may use the elegant swim macro to run your project.
async
Current status
The device has been built, but the batteries are not yet included.
Contributing
Feel free to open an issue or a PR if you have any ideas or suggestions. This project is all about new ideas and making the developer experience better.