Crate serwus

source ·
Expand description

Serwus is a set of helpers for building actix-web/diesel based services.

§Features

  • MultiPool - Master/replica-aware wrapper for r2d2
  • StatsPresenter - Framework for readiness and statistics reporting
  • JsonError - Middleware that makes actix-web return errors as JSONs

§Example

use serwus::{
    server::{Serwus, default_cors},
    EmptyStats,
    web,
};

#[derive(Clone, EmptyStats)]
pub struct AppData;

async fn hello() -> &'static str {
    "Hello world\n"
}

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    let prepare_app_data = || AppData;

    Serwus::default()
        .start(
            prepare_app_data,
            |app| {
                app.route("/", web::get().to(hello));
            },
            default_cors,
        )
        .await
}

Modules§

  • Helpers for user authentication (JWT, 3rd-party)
  • Various structs handy for processing data between database and handlers’ output
  • Helpers for creating r2d2 pool based on ENV variables and number of CPUs.
  • Few helpers for spawning and configuring service in actix ecosystem.
  • Re-export of web from actix-web or from paperclip if swagger feature enabled. Essentials helper functions and types for application registration.

Macros§

Derive Macros§