[][src]Trait coi_actix_web::AppExt

pub trait AppExt {
    fn register_container(self, container: Container) -> Self;
}

Extensions to actix-web's App struct

Required methods

fn register_container(self, container: Container) -> Self

A helper extension method to ensure the Container is properly registered to work with the inject attribute macro.

Examples

use coi_actix_web::AppExt as _;

// Your general server setup in "main". The name here is different
#[actix_rt::main]
async fn main() -> std::io::Result<()> {
    use actix_web::{App, HttpServer};
    use coi::container;

    // Construct your coi container with your keys and providers
    // See the coi crate for more details
    let container = container!{
        service => ServiceImplProvider; scoped
    };

    HttpServer::new(move || {
        App::new()
        .register_container(container.clone())
        // ^^^^^^^^^^^^^^^^
        .service(get)
    })
    .bind("127.0.0.1:8000")?
    .run()
    .await
}

  
Loading content...

Implementations on Foreign Types

impl<S, T> AppExt for App<S, T> where
    S: ServiceFactory<Config = (), Request = ServiceRequest, Response = ServiceResponse<T>, Error = Error, InitError = ()>,
    T: MessageBody
[src]

Loading content...

Implementors

Loading content...