Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handlers: No body response for OPTIONS requests #169

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions handlers/preflight.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

"github.com/labstack/echo/v4"
"github.com/nspcc-dev/neofs-rest-gw/handlers/apiserver"
"github.com/nspcc-dev/neofs-rest-gw/internal/util"
)

const (
Expand Down Expand Up @@ -35,93 +34,93 @@
ctx.Response().Header().Set(accessControlAllowOriginHeader, allOrigins)
ctx.Response().Header().Set(accessControlAllowHeadersHeader, allowHeaders)
ctx.Response().Header().Set(accessControlAllowMethodsHeader, allowMethods(methodPost))
return ctx.JSON(http.StatusOK, util.NewSuccessResponse())
return ctx.NoContent(http.StatusOK)

Check warning on line 37 in handlers/preflight.go

View check run for this annotation

Codecov / codecov/patch

handlers/preflight.go#L37

Added line #L37 was not covered by tests
}

// OptionsAuthBearer handler for the authBearer options request.
func (a *RestAPI) OptionsAuthBearer(ctx echo.Context) error {
ctx.Response().Header().Set(accessControlAllowOriginHeader, allOrigins)
ctx.Response().Header().Set(accessControlAllowHeadersHeader, allowHeaders)
ctx.Response().Header().Set(accessControlAllowMethodsHeader, allowMethods(methodGet))
return ctx.JSON(http.StatusOK, util.NewSuccessResponse())
return ctx.NoContent(http.StatusOK)

Check warning on line 45 in handlers/preflight.go

View check run for this annotation

Codecov / codecov/patch

handlers/preflight.go#L45

Added line #L45 was not covered by tests
}

// OptionsBalance handler for the balance options request.
func (a *RestAPI) OptionsBalance(ctx echo.Context, _ string) error {
ctx.Response().Header().Set(accessControlAllowOriginHeader, allOrigins)
ctx.Response().Header().Set(accessControlAllowHeadersHeader, allowHeaders)
ctx.Response().Header().Set(accessControlAllowMethodsHeader, allowMethods(methodGet))
return ctx.JSON(http.StatusOK, util.NewSuccessResponse())
return ctx.NoContent(http.StatusOK)

Check warning on line 53 in handlers/preflight.go

View check run for this annotation

Codecov / codecov/patch

handlers/preflight.go#L53

Added line #L53 was not covered by tests
}

// OptionsObjectsSearch handler for the objectsSearch options request.
func (a *RestAPI) OptionsObjectsSearch(ctx echo.Context, _ string) error {
ctx.Response().Header().Set(accessControlAllowOriginHeader, allOrigins)
ctx.Response().Header().Set(accessControlAllowHeadersHeader, allowHeaders)
ctx.Response().Header().Set(accessControlAllowMethodsHeader, allowMethods(methodPost))
return ctx.JSON(http.StatusOK, util.NewSuccessResponse())
return ctx.NoContent(http.StatusOK)

Check warning on line 61 in handlers/preflight.go

View check run for this annotation

Codecov / codecov/patch

handlers/preflight.go#L61

Added line #L61 was not covered by tests
}

// OptionsObjectsPut handler for the objectsPut options request.
func (a *RestAPI) OptionsObjectsPut(ctx echo.Context) error {
ctx.Response().Header().Set(accessControlAllowOriginHeader, allOrigins)
ctx.Response().Header().Set(accessControlAllowHeadersHeader, allowHeaders)
ctx.Response().Header().Set(accessControlAllowMethodsHeader, allowMethods(methodPut))
return ctx.JSON(http.StatusOK, util.NewSuccessResponse())
return ctx.NoContent(http.StatusOK)

Check warning on line 69 in handlers/preflight.go

View check run for this annotation

Codecov / codecov/patch

handlers/preflight.go#L69

Added line #L69 was not covered by tests
}

// OptionsObjectsGetDelete handler for the objectsGetDelete options request.
func (a *RestAPI) OptionsObjectsGetDelete(ctx echo.Context, _ apiserver.ContainerId, _ apiserver.ObjectId) error {
ctx.Response().Header().Set(accessControlAllowOriginHeader, allOrigins)
ctx.Response().Header().Set(accessControlAllowHeadersHeader, allowHeaders)
ctx.Response().Header().Set(accessControlAllowMethodsHeader, allowMethods(methodGet, methodDelete))
return ctx.JSON(http.StatusOK, util.NewSuccessResponse())
return ctx.NoContent(http.StatusOK)

Check warning on line 77 in handlers/preflight.go

View check run for this annotation

Codecov / codecov/patch

handlers/preflight.go#L77

Added line #L77 was not covered by tests
}

// OptionsContainersPutList handler for the containersPutList options request.
func (a *RestAPI) OptionsContainersPutList(ctx echo.Context) error {
ctx.Response().Header().Set(accessControlAllowOriginHeader, allOrigins)
ctx.Response().Header().Set(accessControlAllowHeadersHeader, allowHeaders)
ctx.Response().Header().Set(accessControlAllowMethodsHeader, allowMethods(methodGet, methodPut))
return ctx.JSON(http.StatusOK, util.NewSuccessResponse())
return ctx.NoContent(http.StatusOK)

Check warning on line 85 in handlers/preflight.go

View check run for this annotation

Codecov / codecov/patch

handlers/preflight.go#L85

Added line #L85 was not covered by tests
}

// OptionsContainersGetDelete handler for the containersGetDelete options request.
func (a *RestAPI) OptionsContainersGetDelete(ctx echo.Context, _ apiserver.ContainerId) error {
ctx.Response().Header().Set(accessControlAllowOriginHeader, allOrigins)
ctx.Response().Header().Set(accessControlAllowHeadersHeader, allowHeaders)
ctx.Response().Header().Set(accessControlAllowMethodsHeader, allowMethods(methodGet, methodDelete))
return ctx.JSON(http.StatusOK, util.NewSuccessResponse())
return ctx.NoContent(http.StatusOK)

Check warning on line 93 in handlers/preflight.go

View check run for this annotation

Codecov / codecov/patch

handlers/preflight.go#L93

Added line #L93 was not covered by tests
}

// OptionsContainersEACL handler for the containersEACL options request.
func (a *RestAPI) OptionsContainersEACL(ctx echo.Context, _ apiserver.ContainerId) error {
ctx.Response().Header().Set(accessControlAllowOriginHeader, allOrigins)
ctx.Response().Header().Set(accessControlAllowHeadersHeader, allowHeaders)
ctx.Response().Header().Set(accessControlAllowMethodsHeader, allowMethods(methodGet, methodPut))
return ctx.JSON(http.StatusOK, util.NewSuccessResponse())
return ctx.NoContent(http.StatusOK)

Check warning on line 101 in handlers/preflight.go

View check run for this annotation

Codecov / codecov/patch

handlers/preflight.go#L101

Added line #L101 was not covered by tests
}

// OptionsContainerObject handler for the containerObject options request.
func (a *RestAPI) OptionsContainerObject(ctx echo.Context, _ apiserver.ContainerId, _ apiserver.ObjectId) error {
ctx.Response().Header().Set(accessControlAllowOriginHeader, allOrigins)
ctx.Response().Header().Set(accessControlAllowHeadersHeader, allowHeaders)
ctx.Response().Header().Set(accessControlAllowMethodsHeader, allowMethods(methodGet, methodHead))
return ctx.JSON(http.StatusOK, util.NewSuccessResponse())
return ctx.NoContent(http.StatusOK)

Check warning on line 109 in handlers/preflight.go

View check run for this annotation

Codecov / codecov/patch

handlers/preflight.go#L109

Added line #L109 was not covered by tests
}

// OptionsUploadContainerObject handler for the uploadContainerObject options request.
func (a *RestAPI) OptionsUploadContainerObject(ctx echo.Context, _ apiserver.ContainerId) error {
ctx.Response().Header().Set(accessControlAllowOriginHeader, allOrigins)
ctx.Response().Header().Set(accessControlAllowHeadersHeader, allowHeaders)
ctx.Response().Header().Set(accessControlAllowMethodsHeader, allowMethods(methodPost))
return ctx.JSON(http.StatusOK, util.NewSuccessResponse())
return ctx.NoContent(http.StatusOK)

Check warning on line 117 in handlers/preflight.go

View check run for this annotation

Codecov / codecov/patch

handlers/preflight.go#L117

Added line #L117 was not covered by tests
}

// OptionsByAttribute handler for the byAttribute options request.
func (a *RestAPI) OptionsByAttribute(ctx echo.Context, _ apiserver.ContainerId, _ apiserver.AttrKey, _ apiserver.AttrVal) error {
ctx.Response().Header().Set(accessControlAllowOriginHeader, allOrigins)
ctx.Response().Header().Set(accessControlAllowHeadersHeader, allowHeaders)
ctx.Response().Header().Set(accessControlAllowMethodsHeader, allowMethods(methodGet, methodHead))
return ctx.JSON(http.StatusOK, util.NewSuccessResponse())
return ctx.NoContent(http.StatusOK)

Check warning on line 125 in handlers/preflight.go

View check run for this annotation

Codecov / codecov/patch

handlers/preflight.go#L125

Added line #L125 was not covered by tests
}
Loading