notes-server/server/dir.go

27 lines
463 B
Go

package server
import (
"fmt"
"io/ioutil"
"net/http"
)
func notesDir(path Path, w http.ResponseWriter, r *http.Request) {
dirs, files := lsDir(path)
content := dirs.List()
block(content, w)
fmt.Fprintln(w, files.List())
}
func lsDir(path Path) (Paths, Paths) {
dirs := newDirs()
files := newFiles()
found, _ := ioutil.ReadDir(path.Local)
for _, f := range found {
dirs.Push(path, f)
files.Push(path, f)
}
return Paths(*dirs), Paths(*files)
}