Clean lint.
This commit is contained in:
parent
009dd1ff19
commit
3402d7bcf4
18
src/rweb.rs
18
src/rweb.rs
@ -3,20 +3,16 @@ use std::io::Write;
|
|||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use cacher::Cacher;
|
|
||||||
use google_photoslibrary1 as photos;
|
use google_photoslibrary1 as photos;
|
||||||
use log::error;
|
use log::error;
|
||||||
use photos::schemas::{Album, MediaItem};
|
use photos::schemas::{Album, MediaItem};
|
||||||
use prometheus::Encoder;
|
use prometheus::Encoder;
|
||||||
use rocket::error::LaunchError;
|
|
||||||
use rocket::http::ContentType;
|
use rocket::http::ContentType;
|
||||||
use rocket::response::content::Html;
|
|
||||||
use rocket::response::status::NotFound;
|
use rocket::response::status::NotFound;
|
||||||
use rocket::response::Content;
|
use rocket::response::Content;
|
||||||
use rocket::{Request, State};
|
use rocket::State;
|
||||||
use rocket_contrib::json::Json;
|
use rocket_contrib::json::Json;
|
||||||
use rust_embed::RustEmbed;
|
use rust_embed::RustEmbed;
|
||||||
use serde::Deserialize;
|
|
||||||
|
|
||||||
use crate::library::Library;
|
use crate::library::Library;
|
||||||
|
|
||||||
@ -34,22 +30,22 @@ fn metrics() -> Content<Vec<u8>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
fn index(lib: State<Library>) -> Result<Content<Vec<u8>>, NotFound<String>> {
|
fn index() -> Result<Content<Vec<u8>>, NotFound<String>> {
|
||||||
file("index.html", lib)
|
file("index.html")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/<path..>", rank = 99)]
|
#[get("/<path..>", rank = 99)]
|
||||||
fn path(path: PathBuf, lib: State<Library>) -> Result<Content<Vec<u8>>, NotFound<String>> {
|
fn path(path: PathBuf) -> Result<Content<Vec<u8>>, NotFound<String>> {
|
||||||
let path = path.to_str().unwrap();
|
let path = path.to_str().unwrap();
|
||||||
let path = if path.ends_with("/") {
|
let path = if path.ends_with("/") {
|
||||||
format!("{}index.html", path.to_string())
|
format!("{}index.html", path.to_string())
|
||||||
} else {
|
} else {
|
||||||
path.to_string()
|
path.to_string()
|
||||||
};
|
};
|
||||||
file(&path, lib)
|
file(&path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn file(path: &str, lib: State<Library>) -> Result<Content<Vec<u8>>, NotFound<String>> {
|
fn file(path: &str) -> Result<Content<Vec<u8>>, NotFound<String>> {
|
||||||
match Asset::get(path) {
|
match Asset::get(path) {
|
||||||
Some(bytes) => {
|
Some(bytes) => {
|
||||||
let mime = mime_guess::from_path(path).first_or_octet_stream();
|
let mime = mime_guess::from_path(path).first_or_octet_stream();
|
||||||
@ -119,7 +115,7 @@ fn embedz() -> Content<Vec<u8>> {
|
|||||||
Content(ContentType::HTML, w)
|
Content(ContentType::HTML, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run(addr: SocketAddr, lib: Library) -> Result<(), Box<dyn Error>> {
|
pub fn run(_addr: SocketAddr, lib: Library) -> Result<(), Box<dyn Error>> {
|
||||||
let e = rocket::ignite()
|
let e = rocket::ignite()
|
||||||
.manage(lib)
|
.manage(lib)
|
||||||
.mount(
|
.mount(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user