fix error checks and imports
This commit is contained in:
parent
c36f125437
commit
eab0e360e6
1 changed files with 12 additions and 7 deletions
|
@ -2,8 +2,8 @@
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate rocket;
|
extern crate rocket;
|
||||||
|
|
||||||
use std::{str::FromStr, sync::Arc};
|
use std::sync::Arc;
|
||||||
|
use std::str::FromStr;
|
||||||
use chrono::{DateTime, Duration, Utc};
|
use chrono::{DateTime, Duration, Utc};
|
||||||
use libpixiv::PixivAppClient;
|
use libpixiv::PixivAppClient;
|
||||||
use maud::{html, DOCTYPE};
|
use maud::{html, DOCTYPE};
|
||||||
|
@ -33,12 +33,17 @@ async fn handle_route(
|
||||||
|
|
||||||
if let Some(id) = path.file_name() {
|
if let Some(id) = path.file_name() {
|
||||||
let meta = fetch_illust(client, &db, id.to_str().unwrap().parse::<u32>().unwrap());
|
let meta = fetch_illust(client, &db, id.to_str().unwrap().parse::<u32>().unwrap());
|
||||||
Ok(RawHtml(
|
if let Some(meta) = meta.await {
|
||||||
create_page(&target, &meta.await.unwrap()).await.unwrap(),
|
if let Ok(page) = create_page(&target, &meta).await {
|
||||||
))
|
return Ok(RawHtml(page))
|
||||||
} else {
|
}
|
||||||
Err(Status::InternalServerError)
|
} else {
|
||||||
|
println!("High chance of failed login, check token!");
|
||||||
|
return Err(Status::ServiceUnavailable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Err(Status::InternalServerError)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn fetch_illust(
|
async fn fetch_illust(
|
||||||
|
|
Loading…
Add table
Reference in a new issue