lambda-forge 0.1.7

An opinionated API Framework for building AWS Lambda HTTP endpoints.
Documentation
use serde::{Deserialize, Serialize};
use serde_json::{Value, json};

#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ApiResponseBody<T> {
    pub was_successful: bool,
    pub data: Option<T>,
    pub message: Option<String>,
}
impl ApiResponseBody<Value> {
    /// Parse an [`ApiResponse`] into a JSON body string.
    pub fn into_json_body(self) -> String {
        json!({
            "wasSuccessful": self.was_successful,
            "data": self.data,
            "message": self.message,
        })
        .to_string()
    }
}