Limitations of Android, REST, and HATEOAS

So, I am creating a mobile application that will use the RESTful web service (which I also write myself) After many studies, I have a few questions regarding mobile applications and the limitations of HATEOAS.

  • I usually use the Gson library to parse objects without the HATEOAS restriction, and it has been proven to be really efficient. However, for HATEOAS, I am thinking of using Gson for deserialization and Json-HAL for the response format.

    How to analyze all _links and _embedded resources in my application without making the deserialization process tedious? Some objects may have “embedded” resources, and some may not. How do I create data model objects to support all of these new tags? I am pretty lost in this part, so I would like to evaluate an example.

  • Does anyone have any tips on implementing this limitation for mobile apps?

  • If you think that HAL or Json is not suitable for mobile devices, let me know.

The implementation of this limitation for mobile devices seems to me unnecessary.

Please enlighten me, thanks!

+5
source share
1 answer

Beat was late for the party, but I think the best way to solve this is to summarize:

  • Yea HAL is a good format.
  • Treat things in _links and things in _embedded as links. They really are the same. "
  • The difference with _embedded compared to _links is that _embedded really needs to pre-populate your cache. Therefore, everything you get should be added to some kind of cache, which should make future GET requests unnecessary for these resources.

The advantage of this approach is that it is now possible for the server to “promote” links from _links to _embedded , and your client will automatically adapt to this and make fewer HTTP calls.

Links: (disclaimer, I wrote both)

0
source

Source: https://habr.com/ru/post/1201086/


All Articles