bolt-web 3.0.0

⚡ A high-performance, minimalist web framework for Rust, inspired by Express.js and Gin.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use serde_json::json;

use crate::{error, response::ResponseWriter};

async fn default(message: String, res: &mut ResponseWriter) {
    let status = res.get_code(res.status);

    let msg = if status >= 500 {
        "Internal Server Error".to_string()
    } else {
        message
    };

    res.status(res.status)
        .json(&json!({"message": msg , "status" : status }));
}

error!(default);