mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-22 16:24:14 +00:00
33 lines
580 B
Go
33 lines
580 B
Go
|
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))
|
||
|
}
|