webdav: handle REPORT
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package svc
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
searchsvc "github.com/owncloud/ocis/protogen/gen/ocis/services/search/v0"
|
||||
merrors "go-micro.dev/v4/errors"
|
||||
)
|
||||
|
||||
// Search is the endpoint for retrieving search results for REPORT requests
|
||||
func (g Webdav) Search(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
rsp, err := g.searchClient.Search(r.Context(), &searchsvc.SearchRequest{})
|
||||
if err != nil {
|
||||
e := merrors.Parse(err.Error())
|
||||
switch e.Code {
|
||||
case http.StatusBadRequest:
|
||||
renderError(w, r, errBadRequest(err.Error()))
|
||||
default:
|
||||
renderError(w, r, errInternalError(err.Error()))
|
||||
}
|
||||
g.log.Error().Err(err).Msg("could not get search results")
|
||||
return
|
||||
}
|
||||
|
||||
g.sendSearchResponse(rsp, w, r)
|
||||
}
|
||||
|
||||
func (g Webdav) sendSearchResponse(rsp *searchsvc.SearchResponse, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
thumbnailsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/thumbnails/v0"
|
||||
searchsvc "github.com/owncloud/ocis/protogen/gen/ocis/services/search/v0"
|
||||
thumbnailssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/thumbnails/v0"
|
||||
"github.com/owncloud/ocis/webdav/pkg/config"
|
||||
"github.com/owncloud/ocis/webdav/pkg/dav/requests"
|
||||
@@ -62,6 +63,7 @@ func NewService(opts ...Option) (Service, error) {
|
||||
config: conf,
|
||||
log: options.Logger,
|
||||
mux: m,
|
||||
searchClient: searchsvc.NewSearchProviderService("search", grpc.DefaultClient),
|
||||
thumbnailsClient: thumbnailssvc.NewThumbnailService("com.owncloud.api.thumbnails", grpc.DefaultClient),
|
||||
revaClient: gwc,
|
||||
}
|
||||
@@ -71,6 +73,8 @@ func NewService(opts ...Option) (Service, error) {
|
||||
r.Get("/remote.php/dav/files/{id}/*", svc.Thumbnail)
|
||||
r.Get("/remote.php/dav/public-files/{token}/*", svc.PublicThumbnail)
|
||||
r.Head("/remote.php/dav/public-files/{token}/*", svc.PublicThumbnailHead)
|
||||
|
||||
r.MethodFunc("REPORT", "/remote.php/dav/files/{id}/*", svc.Search)
|
||||
})
|
||||
|
||||
return svc, nil
|
||||
@@ -81,6 +85,7 @@ type Webdav struct {
|
||||
config *config.Config
|
||||
log log.Logger
|
||||
mux *chi.Mux
|
||||
searchClient searchsvc.SearchProviderService
|
||||
thumbnailsClient thumbnailssvc.ThumbnailService
|
||||
revaClient gatewayv1beta1.GatewayAPIClient
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user