Crate serwus

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§

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

Macros§

error_logged
return_logged
sanitizableDeprecated
Depreacted, use SanitizedString
wrap_displayDeprecated

Derive Macros§

EmptyStats
Automatic implementation of StatsPresenter