-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
34 lines (25 loc) · 794 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main
import (
"flag"
"log"
"net/http"
"golang.org/x/net/webdav"
)
func logRequest(r *http.Request, err error) {
log.Println(r.RemoteAddr, r.Method, r.URL.Path)
}
func main() {
var address, prefix, webdavDir string
flag.StringVar(&address, "address", "0.0.0.0:8080", "Address to listen to.")
flag.StringVar(&prefix, "prefix", "", "Prefix is the URL path prefix to strip from WebDAV resource paths.")
flag.StringVar(&webdavDir, "webdavDir", ".", "Path to serve")
flag.Parse()
handler := &webdav.Handler{
Prefix: prefix,
FileSystem: webdav.Dir(webdavDir),
LockSystem: webdav.NewMemLS(),
Logger: logRequest,
}
log.Println("serving", webdavDir, "on", address)
http.ListenAndServe(address, handler)
}