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]
|
||||
extern crate rocket;
|
||||
|
||||
use std::{str::FromStr, sync::Arc};
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::str::FromStr;
|
||||
use chrono::{DateTime, Duration, Utc};
|
||||
use libpixiv::PixivAppClient;
|
||||
use maud::{html, DOCTYPE};
|
||||
|
@ -33,12 +33,17 @@ async fn handle_route(
|
|||
|
||||
if let Some(id) = path.file_name() {
|
||||
let meta = fetch_illust(client, &db, id.to_str().unwrap().parse::<u32>().unwrap());
|
||||
Ok(RawHtml(
|
||||
create_page(&target, &meta.await.unwrap()).await.unwrap(),
|
||||
))
|
||||
} else {
|
||||
Err(Status::InternalServerError)
|
||||
if let Some(meta) = meta.await {
|
||||
if let Ok(page) = create_page(&target, &meta).await {
|
||||
return Ok(RawHtml(page))
|
||||
}
|
||||
} else {
|
||||
println!("High chance of failed login, check token!");
|
||||
return Err(Status::ServiceUnavailable);
|
||||
}
|
||||
}
|
||||
Err(Status::InternalServerError)
|
||||
|
||||
}
|
||||
|
||||
async fn fetch_illust(
|
||||
|
|
Loading…
Add table
Reference in a new issue