markdown.rs 406 Bytes
use crate::models::markdown;
use crate::Pool;

use actix_web::{Error, HttpResponse, web};
use anyhow::Result;

pub async fn get_markdowns(pool: web::Data<Pool>)
    -> Result<HttpResponse, Error>
{
    Ok(web::block(move || markdown::get_markdowns(pool.into_inner()))
       . await
       . map(|markdowns| HttpResponse::Ok().json(markdowns))
       . map_err(|_| HttpResponse::InternalServerError())?)
}