agrestio / agrest

Server-side Java REST Framework for easy access to data graphs from various backends
https://agrest.io
Apache License 2.0
80 stars 34 forks source link

Better default encoder for DataResponse #577

Closed andrus closed 2 years ago

andrus commented 2 years ago

Sometimes we can bypass Agrest runtime to generate a quick DataResponse around some POJOs:

return DataResponse.of(200, List.of(o));

Currently this would not render properly, because the default encoder would be the GenericEncoder. Instead let's make DataResponseEncoder the default.

While we are at it, let's refactor factory methods into a builder that would allow to distinguish between the main encoder and individual element encoder in the response