rjapi 0.0.1

A framework-agnostic JSON:API 1.1 implementation for Rust
Documentation
//! Example of error handling with the JSON:API library

use rjapi::{
    bad_request_error, conflict_error, forbidden_error, internal_server_error, not_found_error,
};

fn main() {
    // Create different types of errors
    let bad_request = bad_request_error("Bad Request", "The request was malformed");
    println!(
        "Bad Request Error: {}",
        serde_json::to_string_pretty(&bad_request.to_document::<()>()).unwrap()
    );

    let not_found = not_found_error("Resource not found");
    println!(
        "Not Found Error: {}",
        serde_json::to_string_pretty(&not_found.to_document::<()>()).unwrap()
    );

    let forbidden = forbidden_error("Access denied");
    println!(
        "Forbidden Error: {}",
        serde_json::to_string_pretty(&forbidden.to_document::<()>()).unwrap()
    );

    let conflict = conflict_error("Resource already exists");
    println!(
        "Conflict Error: {}",
        serde_json::to_string_pretty(&conflict.to_document::<()>()).unwrap()
    );

    let internal_error = internal_server_error("Something went wrong");
    println!(
        "Internal Server Error: {}",
        serde_json::to_string_pretty(&internal_error.to_document::<()>()).unwrap()
    );
}