[][src]Crate contraband

Contraband is a web framework for building modular applications in Rust with dependency injection and performant higher-level abstractions. It is build on top of actix-web.

Contraband is heavily inspired by Spring Boot and Nestjs.

Example

use contraband::{Injectable, controller, module};
use contraband::core::ContrabandApp;
use actix_web::HttpResponse;

#[derive(Clone, Injectable)]
struct HelloController;

#[controller]
impl HelloController {
    #[get]
    async fn hello_world(self) -> HttpResponse {
        HttpResponse::Ok().body("Hello world!")
    }
}

#[module]
#[controller(HelloController)]
struct HelloModule;

#[contraband::main]
async fn main() -> std::io::Result<()> {
    ContrabandApp::new()
        .start::<HelloModule>()
        .await
}

Documentation & community resources

Modules

config

Helpers for loading module configuration

core

Core app client

log

Global logging dependency

module

Module generation and configuration

Attribute Macros

controller

Creates a controller.

main

Marks function to be run in an async runtime

module

Creates a module.

test

Marks test function to be run in an async runtime

Derive Macros

Injectable

Derives the Injectable trait for dependency injection.