adjusted requester to supply http::version itself
This commit is contained in:
25
src/proxy.rs
25
src/proxy.rs
@@ -1,6 +1,5 @@
|
||||
use ntex::web::{self, HttpRequest};
|
||||
|
||||
use crate::proxies::noodlemagazine::NoodlemagazineProxy;
|
||||
use crate::proxies::sxyprn::SxyprnProxy;
|
||||
use crate::util::requester::Requester;
|
||||
use crate::proxies::*;
|
||||
@@ -16,16 +15,6 @@ pub fn config(cfg: &mut web::ServiceConfig) {
|
||||
.route(web::post().to(crate::proxies::hanimecdn::get_image))
|
||||
.route(web::get().to(crate::proxies::hanimecdn::get_image)),
|
||||
)
|
||||
.service(
|
||||
web::resource("/noodlemagazine/{endpoint}*")
|
||||
.route(web::post().to(noodlemagazine))
|
||||
.route(web::get().to(noodlemagazine)),
|
||||
)
|
||||
// .service(
|
||||
// web::resource("/videos")
|
||||
// // .route(web::get().to(videos_get))
|
||||
// .route(web::post().to(videos_post)),
|
||||
// )
|
||||
;
|
||||
}
|
||||
|
||||
@@ -43,23 +32,9 @@ async fn sxyprn(req: HttpRequest,
|
||||
.finish())
|
||||
}
|
||||
|
||||
async fn noodlemagazine(req: HttpRequest,
|
||||
requester: web::types::State<Requester>,) -> Result<impl web::Responder, web::Error> {
|
||||
let proxy = get_proxy(req.uri().to_string().split("/").collect::<Vec<&str>>()[2]).unwrap();
|
||||
let endpoint = req.match_info().query("endpoint").to_string();
|
||||
let video_url = match proxy.get_video_url(endpoint, requester).await{
|
||||
url if url != "" => url,
|
||||
_ => "Error".to_string(),
|
||||
};
|
||||
Ok(web::HttpResponse::Found()
|
||||
.header("Location", format!("{}", video_url))
|
||||
.finish())
|
||||
}
|
||||
|
||||
fn get_proxy(proxy: &str) -> Option<AnyProxy> {
|
||||
match proxy {
|
||||
"sxyprn" => Some(AnyProxy::Sxyprn(SxyprnProxy::new())),
|
||||
"noodlemagazine" => Some(AnyProxy::Noodlemagazine(NoodlemagazineProxy::new())),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user