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

JAX-RS - support query param 'format' #501

Closed
rsoika opened this issue May 2, 2019 · 0 comments
Closed

JAX-RS - support query param 'format' #501

rsoika opened this issue May 2, 2019 · 0 comments

Comments

@rsoika
Copy link
Member

rsoika commented May 2, 2019

Extend the rest api with a new optional query param 'format' to allow optional force output in XML or JSON. Currenty we only support the header param 'accept'

Using this param we can switch the ouput format:

@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response service(@QueryParam("format") String format) {
    return Response
            // Set the status and Put your entity here.
            .ok(entity)
            // Add the Content-Type header to tell Jersey which format it should marshall the entity into.
            .header(HttpHeaders.CONTENT_TYPE, "json".equals(format) ? MediaType.APPLICATION_JSON : MediaType.APPLICATION_XML)
            .build();
}

See: https://stackoverflow.com/questions/18026296/jersey-how-to-generate-json-and-xml-output-depending-on-url-param/35112400

@rsoika rsoika added the feature label May 2, 2019
@rsoika rsoika added this to the 4.5.6 milestone May 2, 2019
rsoika added a commit that referenced this issue May 5, 2019
@rsoika rsoika added the testing label May 5, 2019
@rsoika rsoika closed this as completed May 8, 2019
bvfalcon pushed a commit to bvfalcon/imixs-workflow that referenced this issue Jul 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant