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

Create a possible response based on the 'Accept' header of a request #15

Open
MTDdk opened this issue Sep 10, 2015 · 0 comments
Open

Create a possible response based on the 'Accept' header of a request #15

MTDdk opened this issue Sep 10, 2015 · 0 comments

Comments

@MTDdk
Copy link
Owner

MTDdk commented Sep 10, 2015

Instead of explicitly stating return respond().json(object); or return respond().xml(object); it should be possible to just state the object to be returned, and then base the response type on requested 'Accept' header.

This, of course, is not trivial, as we need to handle the possibility that the requested could be html.
Should the object somehow be translated into a reserved keyword for the template engine, like StringTemplate uses it?
Or should the keyword be based on the objects class name and thus possibly break the reusability of the template?

Setting the html issue aside, a proposed return signature could be: return respond(object); or return respond().accept(object); or return respond().asRequested(object);

If one after all still keeps the html issue in mind, the return signature could also be with an optional keyword specifier, like return respond().asRequested("person", object);

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