coi-actix-web
Dependency Injection in Rust
This crate provides integration support between coi
and actix-web
. It
exposes an inject
procedural attribute macro to generate the code for
retrieving your dependencies from a Container
registered with actix-web
.
Example
// What this crate provides
use inject;
// What's needed for the example fn below
use ;
use Arc;
// Add the `inject` attribute to the function you want to inject
async
// Just data models for the above fn
use Serialize;
// An example of what's usually needed to make effective use of this
// crate is below
use Inject;
use ;
// This section shows coi being put to use
// It's very important that the version of coi and the version
// of coi-actix-web used match since coi-actix-web implements
// some coi traits
// Here we're marking a trait as injectable
// And here we're marking a type that's capable of providing the
// above trait
// Normal impl for struct
// Normal impl of trait for struct
// The data that will be passed between services
// Here's the trait from above
// And it's setup below
;
// This is for the register_container function
use AppExt as _;
// Your general server setup in "main". The name here is different
async
See the repo coi-actix-sample
for a more involved example.
License
SPDX-License-Identifier: MIT OR Apache-2.0