Various prototypes and ideas for a webframework written in rust.
This repository serves as a better scratch board which is publicly available.
-
Global state
The framework's state (and user selected modules') is globally available, because:
- It proved effective in writing production code fast
- It makes accessing it from code other than request handlers (i.e. any background task) easier
- There is no need for two instances in one process
-
No generics in module registry
The global state storing all modules' state is called
Registry
. This type is not generic and neither is its builder, because:-
It greatly simplifies the application facing API.
-
It simplifies the module facing API because it only concerns itself the module implemented and doesn't need to interact with other weird generic constructs.
This point is made in comparison with frameworks like
actix-web
andaxum
where implementing a middleware (yes that is a somewhat unfair comparison) involves several generic parameters and trait bounds which are not really of interest to most middleware authors.
-
-
Dependant modules have to depend on an explicit module instead of their functionality
For example one might implement a customer module named
MyModule
which wants to send emails.Instead of implementing the required logic on its own,
MyModule
chooses to depend on theMailModule
from the framework's contrib section.However now the application author wanting to use
MyModule
has to useMailModule
even though there is an alternativeSuperiorMailModule
which better fits the application's needs.This situation illustrates that ideally a module doesn't depend on another one, but instead it depends on the server having a certain capability (provided through some module).
I have not looked into capabilities a lot, but I fear they might conflict with design decisions 2.