index : static-web-server.git

ascending towards madness

author Jose Quintana <joseluisquintana20@gmail.com> 2021-05-18 7:55:50.0 +00:00:00
committer Jose Quintana <joseluisquintana20@gmail.com> 2021-05-18 7:55:50.0 +00:00:00
commit
c8f5093125294d5df2d8add428878d1eec2450ca [patch]
tree
86c0eb0ed15ff84d8a8781b1d52d3396c0e5d819
parent
84e011a348408b274549fa4ed67c7a985d34071f
download
c8f5093125294d5df2d8add428878d1eec2450ca.tar.gz

refactor: use generic result type



Diff

 src/static_files.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/static_files.rs b/src/static_files.rs
index f7d5901..2f619e5 100644
--- a/src/static_files.rs
+++ b/src/static_files.rs
@@ -25,6 +25,8 @@ use tokio::fs::File as TkFile;
use tokio::io::AsyncSeekExt;
use tokio_util::io::poll_read_buf;

use crate::error::Result;

/// A small Arch `PathBuf` wrapper since Arc<PathBuf> doesn't implement AsRef<Path>.
#[derive(Clone, Debug)]
pub struct ArcPath(pub Arc<PathBuf>);
@@ -155,7 +157,7 @@ async fn read_directory_entries(
    mut entries: tokio::fs::ReadDir,
    base_path: &str,
    is_head: bool,
) -> crate::error::Result<Response<Body>> {
) -> Result<Response<Body>> {
    let mut entries_str = String::new();
    if base_path != "/" {
        entries_str = String::from(r#"<tr><td colspan="3"><a href="../">../</a></td></tr>"#);
@@ -230,8 +232,6 @@ fn file_reply(
    headers: &HeaderMap<HeaderValue>,
    res: (ArcPath, Metadata, bool),
) -> impl Future<Output = Result<Response<Body>, StatusCode>> + Send {
    // TODO: directory listing

    let (path, meta, auto_index) = res;
    let conditionals = get_conditional_headers(headers);
    TkFile::open(path.clone()).then(move |res| match res {