cmd/webdav-server: new command

This commit is contained in:
Simon Ser 2020-01-22 13:17:52 +01:00
parent 6d229f4e8a
commit 59ad6f4d76
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

32
cmd/webdav-server/main.go Normal file
View File

@ -0,0 +1,32 @@
package main
import (
"flag"
"fmt"
"log"
"net/http"
"os"
"github.com/emersion/go-webdav"
)
func main() {
var addr string
flag.StringVar(&addr, "addr", ":8080", "listening address")
flag.Usage = func() {
fmt.Fprintf(flag.CommandLine.Output(), "usage: %s [options...] [directory]\n", os.Args[0])
flag.PrintDefaults()
}
flag.Parse()
path := flag.Arg(0)
if path == "" {
path = "."
}
handler := webdav.Handler{
FileSystem: webdav.LocalFileSystem(path),
}
log.Printf("WebDAV server listening on %v", addr)
log.Fatal(http.ListenAndServe(addr, &handler))
}