aboutsummaryrefslogblamecommitdiff
path: root/webdav.go
blob: 3f3f7d5e25de2b80ae2f991d6a9829c5f6ee637c (plain) (tree)



























                                                                                             
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)
	})
}