diff options
author | Quentin <quentin@deuxfleurs.fr> | 2021-08-23 20:40:03 +0200 |
---|---|---|
committer | Quentin <quentin@deuxfleurs.fr> | 2021-08-23 20:40:03 +0200 |
commit | 15e4d10fd4b35a2e70cc4fa6ad4117cd5c402cbc (patch) | |
tree | 0fe31ac79d5dbe480b1b386845b3dd8fcaa55bd4 /webdav.go | |
parent | 5d64be33e64eb75160b6fe37b01997de7e96237a (diff) | |
download | bagage-15e4d10fd4b35a2e70cc4fa6ad4117cd5c402cbc.tar.gz bagage-15e4d10fd4b35a2e70cc4fa6ad4117cd5c402cbc.zip |
Refactor the codebase
Diffstat (limited to 'webdav.go')
-rw-r--r-- | webdav.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/webdav.go b/webdav.go new file mode 100644 index 0000000..3f3f7d5 --- /dev/null +++ b/webdav.go @@ -0,0 +1,28 @@ +package main + +import ( + "github.com/minio/minio-go/v7" + "golang.org/x/net/webdav" + "log" + "net/http" +) + +type WebDav struct { + WithConfig *Config +} + +func (wd WebDav) WithMC(mc *minio.Client) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + (&webdav.Handler{ + Prefix: wd.WithConfig.DavPath, + FileSystem: NewS3FS(mc), + LockSystem: webdav.NewMemLS(), + Logger: func(r *http.Request, err error) { + log.Printf("INFO: %s %s %s\n", r.RemoteAddr, r.Method, r.URL) + if err != nil { + log.Printf("ERR: %v", err) + } + }, + }).ServeHTTP(w, r) + }) +} |