Introduction
more-di-axum is a crate which provides dependency injection (DI) extensions for the axum web framework. Any trait
or struct can be used as an injected service.
axum provides a dependency injection example; however, it is very limited. axum does not have, nor provide, a
fully-fledged DI framework. State in axum must support Clone and is copied many times within the pipeline. In
particular, the native State model does not intrinsically support a scoped (e.g. per-request) lifetime. This is a
limitation of Clone. A state can be wrapped in Arc as a singleton; otherwise, it is transient. more-di-axum
brings full support for various lifetimes by layering over the more-di library and makes them ergonomic to consume
within axum. Since more-di is a complete DI framework, swapping out dependency registration in different contexts,
such as testing, is trivial.
Contributing
more-di-axum is free and open source. You can find the source code on GitHub and issues and feature
requests can be posted on the GitHub issue tracker. more-di-axum relies on the community to fix bugs and add
features: if you’d like to contribute, please read the CONTRIBUTING guide and consider opening a pull request.
License
This project is licensed under the MIT license.