From 42064fd64ccb2e9e006df1b6365a243d6496b013 Mon Sep 17 00:00:00 2001 From: Caleb Gardner Date: Fri, 23 Aug 2024 18:03:25 -0500 Subject: [PATCH] Added mod time to files --- files.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/files.go b/files.go index 6097906..46d5493 100644 --- a/files.go +++ b/files.go @@ -6,9 +6,10 @@ import ( "net/http" "os" "path/filepath" + "time" ) -const fileElement = "

%v

" +const fileElement = "

%v

%v

" func filesRequest(w http.ResponseWriter, r *http.Request) { partPath := filepath.Clean(r.URL.Path) @@ -38,7 +39,8 @@ func filesRequest(w http.ResponseWriter, r *http.Request) { if f.IsDir() { continue } - pageContent += fmt.Sprintf(fileElement, filepath.Join(partPath, f.Name()), f.Name()) + inf, _ := f.Info() + pageContent += fmt.Sprintf(fileElement, filepath.Join(partPath, f.Name()), f.Name(), inf.ModTime().Format(time.DateOnly)) } } else { http.ServeFile(w, r, path)