Added readable mode for article content

This commit is contained in:
2023-10-15 17:44:05 +02:00
parent 3d77c6f30f
commit ee80cbd53b
17 changed files with 151 additions and 53 deletions
+19
View File
@@ -0,0 +1,19 @@
use actix_web::{web, HttpRequest, Responder};
use crate::json_serialization::{readable::Readable, url::UrlJson};
use super::scraper::content::do_throttled_request;
pub async fn read(_req: HttpRequest, data: web::Json<UrlJson>) -> impl Responder {
let result = do_throttled_request(&data.url);
let content = match result.await {
Ok(cont) => cont,
Err(e) => {
log::error!("Could not scrap url {}", data.url);
e.to_string()
}
};
Readable { content }
}