use rocket::{http::Status, serde::json::Json};

use crate::model::custom_label::CustomLabel;

#[get("/label")]
pub async fn get_all() -> (Status, Json<Vec<CustomLabel>>) {
    match CustomLabel::get_all().await {
        Ok(data) => (Status::Ok, Json(data)),
        Err(err) => {
            eprintln!("Error getting custom labels: {}", err);

            (Status::InternalServerError, Json(vec![]))
        }
    }
}
