caching
This commit is contained in:
@@ -3,6 +3,7 @@ use ntex::web;
|
||||
use ntex::web::HttpRequest;
|
||||
|
||||
use crate::providers::perverzija::PerverzijaProvider;
|
||||
use crate::util::cache::VideoCache;
|
||||
use crate::{providers::*, status::*, videos::*};
|
||||
|
||||
pub fn config(cfg: &mut web::ServiceConfig) {
|
||||
@@ -163,6 +164,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
|
||||
async fn videos_post(
|
||||
video_request: web::types::Json<Videos_Request>,
|
||||
cache: web::types::State<VideoCache>
|
||||
) -> Result<impl web::Responder, web::Error> {
|
||||
let mut videos = Videos {
|
||||
pageInfo: PageInfo {
|
||||
@@ -198,7 +200,7 @@ async fn videos_post(
|
||||
let featured = video_request.featured.as_deref().unwrap_or("all").to_string();
|
||||
let provider = PerverzijaProvider::new();
|
||||
let video_items = provider
|
||||
.get_videos(channel, sort, query, page.to_string(), perPage.to_string(), featured)
|
||||
.get_videos(cache.get_ref().clone(), channel, sort, query, page.to_string(), perPage.to_string(), featured)
|
||||
.await;
|
||||
videos.items = video_items.clone();
|
||||
Ok(web::HttpResponse::Ok().json(&videos))
|
||||
|
||||
Reference in New Issue
Block a user