✨ Implement WebDAV server
This commit is contained in:
@@ -34,10 +34,16 @@ import (
|
||||
"github.com/alecthomas/kong"
|
||||
)
|
||||
|
||||
type config struct {
|
||||
DataDirectory string `name:"data-dir" default:"data" help:"Directory to store all files in."`
|
||||
Db string `name:"db" default:"ShareDAV.db" help:"Database file to use."`
|
||||
}
|
||||
|
||||
type app struct {
|
||||
config
|
||||
CmdUser CmdUser `cmd:"" name:"user" help:"Manage users."`
|
||||
CmdShare CmdShare `cmd:"" name:"share" help:"Manage shares."`
|
||||
CmdServe CmdServe `cmd:"" name:"serve" help:"Serve HTTP requests." default:"1"`
|
||||
|
||||
userStore UserStore
|
||||
shareStore ShareStore
|
||||
@@ -63,40 +69,4 @@ func main() {
|
||||
app.shareStore = store
|
||||
|
||||
ctx.FatalIfErrorf(ctx.Run(&app))
|
||||
|
||||
//c := LoadConfig(*configFile)
|
||||
//
|
||||
//h := &webdav.Handler{}
|
||||
//h.Prefix = "/share/"
|
||||
//h.LockSystem = webdav.NewMemLS()
|
||||
//h.FileSystem = BaseDir(c.BaseDirectory)
|
||||
//
|
||||
//authenticatedWebdavHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
// username, password, ok := r.BasicAuth()
|
||||
// directory := ""
|
||||
// if ok {
|
||||
// ok, directory = c.ValidateDAVUser(username, password)
|
||||
// }
|
||||
// if !ok {
|
||||
// w.Header().Set("WWW-Authenticate", `Basic realm="ShareDAV"`)
|
||||
// http.Error(w, "unauthorized", http.StatusUnauthorized)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// shareName := chi.URLParam(r, "share")
|
||||
// directoryMapping := DirectoryMapping{
|
||||
// VirtualName: shareName,
|
||||
// RealName: directory,
|
||||
// }
|
||||
//
|
||||
// // Use the WebDAV handler to actually serve the request. Also enhance the context
|
||||
// // to contain the subdirectory (of the base directory) which contains the data for
|
||||
// // the authenticated user.
|
||||
// h.ServeHTTP(w, r.WithContext(context.WithValue(r.Context(), "mapping", &directoryMapping)))
|
||||
//})
|
||||
//
|
||||
//r := chi.NewRouter()
|
||||
//r.Handle("/share/{share}/*", authenticatedWebdavHandler)
|
||||
//
|
||||
//http.ListenAndServe(c.ListenAddress, r)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user