pmc 2.0.0

PMC is a simple and easy to use PM2 alternative
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use super::structs::ErrorMessage;
use rocket::{http::Status, response::status, serde::json::Json};

pub(crate) type NotFound = status::NotFound<Json<ErrorMessage>>;
pub(crate) type GenericError = status::Custom<Json<ErrorMessage>>;

pub(crate) fn create_status(code: Status) -> Json<ErrorMessage> { Json(ErrorMessage { code, message: code.to_string() }) }

pub(crate) fn generic_error(code: Status, message: String) -> GenericError { status::Custom(code, Json(ErrorMessage { code, message })) }

pub(crate) fn not_found(msg: &str) -> NotFound {
    status::NotFound(Json(ErrorMessage {
        code: Status::NotFound,
        message: msg.to_string(),
    }))
}