From 4f042aa071fae11a5e8b1f0caf927a2ba048e37e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Wed, 6 Jul 2022 15:58:26 +0200 Subject: [PATCH] Wire up the search service at the old webdav endpoint --- services/proxy/pkg/config/defaults/defaultconfig.go | 13 +++++++++---- services/webdav/pkg/service/v0/service.go | 3 ++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/services/proxy/pkg/config/defaults/defaultconfig.go b/services/proxy/pkg/config/defaults/defaultconfig.go index 566373002a..962f185352 100644 --- a/services/proxy/pkg/config/defaults/defaultconfig.go +++ b/services/proxy/pkg/config/defaults/defaultconfig.go @@ -97,15 +97,20 @@ func DefaultPolicies() []config.Policy { Endpoint: "/remote.php/?preview=1", Backend: "http://localhost:9115", }, + // TODO the actual REPORT goes to /dav/files/{username}, which is user specific ... how would this work in a spaces world? + // TODO what paths are returned? the href contains the full path so it should be possible to return urls from other spaces? + // TODO or we allow a REPORT on /dav/spaces to search all spaces and /dav/space/{spaceid} to search a specific space + // send webdav REPORT requests to search service { - // TODO the actual REPORT goes to /dav/files/{username}, which is user specific ... how would this work in a spaces world? - // TODO what paths are returned? the href contains the full path so it should be possible to return urls from other spaces? - // TODO or we allow a REPORT on /dav/spaces to search all spaces and /dav/space/{spaceid} to search a specific space - // send webdav REPORT requests to search service Method: "REPORT", Endpoint: "/remote.php/dav/", Backend: "http://localhost:9115", // TODO use registry? }, + { + Method: "REPORT", + Endpoint: "/remote.php/webdav", + Backend: "http://localhost:9115", // TODO use registry? + }, { Type: config.QueryRoute, Endpoint: "/dav/?preview=1", diff --git a/services/webdav/pkg/service/v0/service.go b/services/webdav/pkg/service/v0/service.go index 89f60fe583..52190901fb 100644 --- a/services/webdav/pkg/service/v0/service.go +++ b/services/webdav/pkg/service/v0/service.go @@ -113,7 +113,8 @@ func NewService(opts ...Option) (Service, error) { // back to using `chi.RegisterMethod`. m.MethodNotAllowed(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { routePrefix := path.Join(options.Config.HTTP.Root, "/remote.php/dav/files/") - if req.Method == "REPORT" && strings.HasPrefix(req.URL.Path, routePrefix) { + legacyRoutePrefix := path.Join(options.Config.HTTP.Root, "/remote.php/webdav") + if req.Method == "REPORT" && (strings.HasPrefix(req.URL.Path, routePrefix) || strings.HasPrefix(req.URL.Path, legacyRoutePrefix)) { // The URLParam will not be available here. If it is needed it // needs to be passed manually or chi needs to be fixed // To use it properly.