Added readable mode for article content
This commit is contained in:
@@ -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 }
|
||||
}
|
||||
Reference in New Issue
Block a user