mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-22 00:04:19 +00:00
cmd/webdav-server: new command
This commit is contained in:
parent
6d229f4e8a
commit
59ad6f4d76
32
cmd/webdav-server/main.go
Normal file
32
cmd/webdav-server/main.go
Normal 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))
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user