Skip to content

Commit

Permalink
Move chi HTTP-Method registering into the NewService func
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Richter <[email protected]>
  • Loading branch information
dragonchaser committed Jun 4, 2024
1 parent 1012a39 commit 6bb593e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 2 additions & 0 deletions services/thumbnails/pkg/service/grpc/v0/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func (g Thumbnail) handleCS3Source(ctx context.Context, req *thumbnailssvc.GetTh
return "", merrors.Forbidden(g.serviceID, "no download permission")
}

//nolint:dupl
tType := thumbnail.GetExtForMime(sRes.GetInfo().GetMimeType())
if tType == "" {
tType = req.GetThumbnailType().String()
Expand Down Expand Up @@ -214,6 +215,7 @@ func (g Thumbnail) handleWebdavSource(ctx context.Context, req *thumbnailssvc.Ge
return "", merrors.Forbidden(g.serviceID, "no download permission")
}

//nolint:dupl
tType := thumbnail.GetExtForMime(sRes.GetInfo().GetMimeType())
if tType == "" {
tType = req.GetThumbnailType().String()
Expand Down
9 changes: 4 additions & 5 deletions services/webdav/pkg/service/v0/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ import (
"github.com/owncloud/ocis/v2/services/webdav/pkg/dav/requests"
)

func init() {
// register method with chi before any routing is set up
chi.RegisterMethod("REPORT")
}

var (
codesEnum = map[int]string{
http.StatusBadRequest: "Sabre\\DAV\\Exception\\BadRequest",
Expand Down Expand Up @@ -94,6 +89,10 @@ func NewService(opts ...Option) (Service, error) {
if svc.config.DisablePreviews {
svc.thumbnailsClient = nil
}

// register method with chi before any routing is set up
chi.RegisterMethod("REPORT")

m.Route(options.Config.HTTP.Root, func(r chi.Router) {

if !svc.config.DisablePreviews {
Expand Down

0 comments on commit 6bb593e

Please sign in to comment.