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

ServerRequestFilter Example if-else bug #40195

Closed
Petkomat opened this issue Apr 12, 2024 · 1 comment · Fixed by #40476
Closed

ServerRequestFilter Example if-else bug #40195

Petkomat opened this issue Apr 12, 2024 · 1 comment · Fixed by #40476

Comments

@Petkomat
Copy link

Describe the bug

The method below disallows (only) GET requests rather than allows them (as claimed in the comment):

import java.util.Optional;

class Filters {
    @ServerRequestFilter
    public Optional<RestResponse<Void>> getFilter(ContainerRequestContext ctx) {
        // only allow GET methods for now
        if(ctx.getMethod().equals(HttpMethod.GET)) {
            return Optional.of(RestResponse.status(Response.Status.METHOD_NOT_ALLOWED));
        }
        return Optional.empty();
    }
}

Which pages

https://quarkus.io/guides/rest#request-or-response-filters

@maxandersen maxandersen transferred this issue from quarkusio/quarkusio.github.io Apr 22, 2024
maxandersen added a commit to maxandersen/quarkus that referenced this issue May 6, 2024
@maxandersen
Copy link
Member

thanks for noticing. opened #40476 to fix this.

@quarkus-bot quarkus-bot bot added this to the 3.11 - main milestone May 6, 2024
gsmet pushed a commit to gsmet/quarkus that referenced this issue May 10, 2024
(cherry picked from commit c89c096)
holly-cummins pushed a commit to holly-cummins/quarkus that referenced this issue Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants