WebDAV: Refactor logging
This commit is contained in:
parent
af71e5f704
commit
65fd839bcf
2 changed files with 40 additions and 19 deletions
18
internal/server/methods.go
Normal file
18
internal/server/methods.go
Normal file
|
@ -0,0 +1,18 @@
|
|||
package server
|
||||
|
||||
const (
|
||||
MethodHead = "HEAD"
|
||||
MethodGet = "GET"
|
||||
MethodPut = "PUT"
|
||||
MethodPost = "POST"
|
||||
MethodPatch = "PATCH"
|
||||
MethodDelete = "DELETE"
|
||||
MethodOptions = "OPTIONS"
|
||||
MethodMkcol = "MKCOL"
|
||||
MethodCopy = "COPY"
|
||||
MethodMove = "MOVE"
|
||||
MethodLock = "LOCK"
|
||||
MethodUnlock = "UNLOCK"
|
||||
MethodPropfind = "PROPFIND"
|
||||
MethodProppatch = "PROPPATCH"
|
||||
)
|
|
@ -3,6 +3,8 @@ package server
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/photoprism/photoprism/pkg/txt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/photoprism/photoprism/internal/auto"
|
||||
"github.com/photoprism/photoprism/internal/config"
|
||||
|
@ -33,17 +35,17 @@ func WebDAV(path string, router *gin.RouterGroup, conf *config.Config) {
|
|||
Logger: func(r *http.Request, err error) {
|
||||
if err != nil {
|
||||
switch r.Method {
|
||||
case "POST", "DELETE", "PUT", "MKCOL", "COPY", "MOVE", "LOCK", "UNLOCK":
|
||||
log.Errorf("webdav-error: %s in %s %s", err, r.Method, r.URL)
|
||||
case "PROPFIND":
|
||||
log.Tracef("webdav-error: %s in %s %s", err, r.Method, r.URL)
|
||||
case MethodPut, MethodPost, MethodPatch, MethodDelete, MethodCopy, MethodMove:
|
||||
log.Errorf("webdav: %s in %s %s", txt.Quote(err.Error()), r.Method, r.URL)
|
||||
case MethodPropfind:
|
||||
log.Tracef("webdav: %s in %s %s", txt.Quote(err.Error()), r.Method, r.URL)
|
||||
default:
|
||||
log.Debugf("webdav-error: %s in %s %s", err, r.Method, r.URL)
|
||||
log.Debugf("webdav: %s in %s %s", txt.Quote(err.Error()), r.Method, r.URL)
|
||||
}
|
||||
|
||||
} else {
|
||||
switch r.Method {
|
||||
case "POST", "DELETE", "PUT", "COPY", "MOVE":
|
||||
case MethodPut, MethodPost, MethodPatch, MethodDelete, MethodCopy, MethodMove:
|
||||
log.Infof("webdav: %s %s", r.Method, r.URL)
|
||||
|
||||
if router.BasePath() == WebDAVOriginals {
|
||||
|
@ -65,17 +67,18 @@ func WebDAV(path string, router *gin.RouterGroup, conf *config.Config) {
|
|||
srv.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
router.Handle("OPTIONS", "/*path", handler)
|
||||
router.Handle("GET", "/*path", handler)
|
||||
router.Handle("HEAD", "/*path", handler)
|
||||
router.Handle("POST", "/*path", handler)
|
||||
router.Handle("DELETE", "/*path", handler)
|
||||
router.Handle("PUT", "/*path", handler)
|
||||
router.Handle("MKCOL", "/*path", handler)
|
||||
router.Handle("COPY", "/*path", handler)
|
||||
router.Handle("MOVE", "/*path", handler)
|
||||
router.Handle("LOCK", "/*path", handler)
|
||||
router.Handle("UNLOCK", "/*path", handler)
|
||||
router.Handle("PROPFIND", "/*path", handler)
|
||||
router.Handle("PROPPATCH", "/*path", handler)
|
||||
router.Handle(MethodHead, "/*path", handler)
|
||||
router.Handle(MethodGet, "/*path", handler)
|
||||
router.Handle(MethodPut, "/*path", handler)
|
||||
router.Handle(MethodPost, "/*path", handler)
|
||||
router.Handle(MethodPatch, "/*path", handler)
|
||||
router.Handle(MethodDelete, "/*path", handler)
|
||||
router.Handle(MethodOptions, "/*path", handler)
|
||||
router.Handle(MethodMkcol, "/*path", handler)
|
||||
router.Handle(MethodCopy, "/*path", handler)
|
||||
router.Handle(MethodMove, "/*path", handler)
|
||||
router.Handle(MethodLock, "/*path", handler)
|
||||
router.Handle(MethodUnlock, "/*path", handler)
|
||||
router.Handle(MethodPropfind, "/*path", handler)
|
||||
router.Handle(MethodProppatch, "/*path", handler)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue