mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-12-22 12:51:16 +00:00
29 lines
654 B
Go
29 lines
654 B
Go
package overlays
|
|
|
|
import (
|
|
"net/http"
|
|
"os"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
"golang.org/x/net/webdav"
|
|
)
|
|
|
|
func getDAVHandler() http.HandlerFunc {
|
|
overlaysDir := os.Getenv("OVERLAYS_DIR")
|
|
if ds, err := os.Stat(overlaysDir); err != nil || overlaysDir == "" || !ds.IsDir() {
|
|
return http.NotFound
|
|
}
|
|
|
|
return (&webdav.Handler{
|
|
Prefix: "/overlays/dav",
|
|
FileSystem: webdav.Dir(overlaysDir),
|
|
LockSystem: webdav.NewMemLS(),
|
|
Logger: func(r *http.Request, err error) {
|
|
logger := logrus.WithField("module", "overlays-dav")
|
|
if err != nil {
|
|
logger = logger.WithError(err)
|
|
}
|
|
logger.Debugf("%s %s", r.Method, r.URL)
|
|
},
|
|
}).ServeHTTP
|
|
}
|