serwus

Crates.ioserwus
lib.rsserwus
version0.2.0
sourcesrc
created_at2023-09-26 06:54:51.292765
updated_at2024-04-22 11:56:26.612193
descriptionHelpers for building actix-web/diesel based services
homepagehttps://github.com/sfisol/serwus
repositoryhttps://github.com/sfisol/serwus
max_upload_size
id983352
size104,782
MichaƂ Pokrywka (sfisol)

documentation

https://docs.rs/serwus/

README

Serwus

Helpers for building actix-web/diesel based services.

crates.io Documentation MIT or Apache 2.0 licensed Dependency Status CI downloads

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 actix_web::web;
use serwus::{
    server::{Serwus, default_cors},
    EmptyStats
};

#[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
}
Commit count: 108

cargo fmt