coi-actix-web 0.4.0

coi-actix-web provides integration support between coi and actix-web
Documentation

coi-actix-web

Build Status docs.rs crates.io

Dependency Injection in Rust

This crate provides integration support between coi and actix-web.

Example

In your Cargo.toml

[dependencies]
coi = { package = "coi-actix-web", version = "0.4.0" }

Note

It's important to rename the package to coi since it re-exports proc-macros from the coi crate, which expects the crate to be named coi.

and in your code:

use coi::inject;
...

#[inject]
async get_all(#[inject] service: Arc<dyn IService>) -> Result<impl Responder, ()> {
    let name = service.get(*id).await.map_err(|e| log::error!("{}", e))?;
    Ok(HttpResponse::Ok().json(DataDto::from(name)))
}

See coi-actix-sample for a more involved example.

License

SPDX-License-Identifier: MIT OR Apache-2.0