eclipse-ee4j / eclipse-ee4j/jersey

Setting default success status code

Open
#3,266 3 comments 0 reactions 0 assignees View on GitHub
Priority: Minor Type: Improvement
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

It would be nice to be able to set the desired success status code via annotation:

```
@Path("/test")
public interface TestEndpoint {

@POST
@SuccessStatus(ACCEPTED)
ProcessingInfo asyncPost(
TestResource resource
);
}
```

or/and ContainerResponseContext:

```
public class TestEndpointImpl implements TestEndpoint {

private ContainerResponseContext responseContext;

public TestEndpointImpl(@Context ContainerResponseContext responseContext) {
this.responseContext = responseContext;
}

@Override
public ProcessingInfo asyncPost(TestResource resource) {
responseContext.setDesiredSuccessStatusCode(ACCEPTED);
// ... processing ...
return processingInfo;
}

}
```

It's useful if you don't want to use the Response class in your interfaces.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing how Jersey handles successful response status codes for resource methods, then compare the proposed @SuccessStatus annotation with ContainerResponseContext#setDesiredSuccessStatusCode. Check the existing response-processing tests and examples, if present. Done means one supported approach is defined, implemented, and covered by tests without requiring Response in the resource interface.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.