Working Index handler.
This commit is contained in:
parent
5f2b69ee3c
commit
ef920126c3
@ -2,8 +2,13 @@ package handlers
|
||||
|
||||
import (
|
||||
"dwelling-files/pkg/files"
|
||||
"dwelling-files/pkg/server"
|
||||
"dwelling-files/pkg/utils"
|
||||
"dwelling-files/web"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/julienschmidt/httprouter"
|
||||
)
|
||||
|
||||
type IndexData struct {
|
||||
@ -34,10 +39,15 @@ func (FilesHandlers) Robots(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (h *FilesHandlers) Index(w http.ResponseWriter, r *http.Request) {
|
||||
currentPath := ""
|
||||
var totalFiles int64 = 0
|
||||
var totalFilesSize int64 = 0
|
||||
var totalDirectories int64 = 0
|
||||
path := httprouter.CleanPath(server.GetURLParam(r, "filepath"))
|
||||
|
||||
web.Index(r.Host, currentPath, totalFiles, totalFilesSize, totalDirectories, nil, r, w)
|
||||
currentPath := files.CurrentPath(path)
|
||||
|
||||
entries, stats, err := files.ScanDirectory(h.directoryPath+path, path)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
web.Index(utils.MainSite(r.Host), currentPath, &stats, &entries, r, w)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user