Skip to content

Better control of response types in REST servlet from the operation #16

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

Open
stcarrez opened this issue Dec 1, 2024 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@stcarrez
Copy link
Owner

stcarrez commented Dec 1, 2024

The REST servlet chooses the response type based on the accepted client types and it configures the stream object accordingly. The operation does not choose and cannot change.

This is easier for the operation but for some requests it may need a different content type. A typical example is a REST api that produces some image or binary content when the image is found but need to produce a JSON error description when the image is not found.

@stcarrez stcarrez added the enhancement New feature or request label Dec 1, 2024
stcarrez added a commit that referenced this issue Dec 1, 2024
- add a Dynamic output stream whose real implementation can be
  customized later either for XML, JSON, or raw mode with the
  dedicated implementation allocated dynamically
- add a Get_Output_Stream on the Response to build an XML, JSON
  or a Dynamic output stream
- add in the operation definition a list of supported stream types
- update the REST servlet to choose the appropriate output stream
  according to what the operation supports, the defined mime types
  and the Accept request header
stcarrez added a commit that referenced this issue Dec 1, 2024
- add new test files for the test
stcarrez added a commit that referenced this issue Dec 1, 2024
- extract from the REST tests a generic package that can configure
  the definition of the REST operation to use specific stream types
- instantiate REST tests for JSON, XML, Dynamic output stream
- update tests to check the content-type and ask for specific
  content in the Accept header
stcarrez added a commit that referenced this issue Dec 1, 2024
- fix default streams configuration to disable DYNAMIC by default
  so that we have the compatibility with existing operations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant