Clean lint.

This commit is contained in:
Bill Thiede 2020-06-20 20:08:37 -07:00
parent 009dd1ff19
commit 3402d7bcf4

View File

@ -3,20 +3,16 @@ use std::io::Write;
use std::net::SocketAddr;
use std::path::PathBuf;
use cacher::Cacher;
use google_photoslibrary1 as photos;
use log::error;
use photos::schemas::{Album, MediaItem};
use prometheus::Encoder;
use rocket::error::LaunchError;
use rocket::http::ContentType;
use rocket::response::content::Html;
use rocket::response::status::NotFound;
use rocket::response::Content;
use rocket::{Request, State};
use rocket::State;
use rocket_contrib::json::Json;
use rust_embed::RustEmbed;
use serde::Deserialize;
use crate::library::Library;
@ -34,22 +30,22 @@ fn metrics() -> Content<Vec<u8>> {
}
#[get("/")]
fn index(lib: State<Library>) -> Result<Content<Vec<u8>>, NotFound<String>> {
file("index.html", lib)
fn index() -> Result<Content<Vec<u8>>, NotFound<String>> {
file("index.html")
}
#[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 = if path.ends_with("/") {
format!("{}index.html", path.to_string())
} else {
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) {
Some(bytes) => {
let mime = mime_guess::from_path(path).first_or_octet_stream();
@ -119,7 +115,7 @@ fn embedz() -> Content<Vec<u8>> {
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()
.manage(lib)
.mount(