Spring HATEOAS adaptation to existing systems

Lately i was involved in lot of discussion at work whether HATEOAS is a good option for our new REST application which would serve as an interface to multiple back-end services we have been building  .

I believe there is no need for me explain the concept of HATEOAS here as there are good enough materials on web. Its easy to write and a sample code can be found here .

One of the best read i find being this , as the comments section in this blog is filled with very bright discussions.

Let me confess my personal experience on GUI side is limited one . So when I spoke about the idea of using HATEOAS , GUI developers were all over me to tell me how difficult it would get for them if we don’t have static URL’s for their buttons/links to act upon. And also how would we adapt to this change to existing GUI’s

Firstly , i had to convince the web developer to read about Richardson Maturity model as most of them had forgotten that we need to progress from Verbs to Hypermedia Controls. Once i did that we were able to start working on new GUI’s using HATEOAS pattern .

But now came the problem to fix the existing GUI’s to use HATEOAS which was more tricky , and as any normal project budget to re-write is always a constraint. So we came up with 2 step solution

  • We decided not to change our current Rest API application and let it run as it runs now using SPRING MVC ,  but any request to it would be re-directed to our new application which was written with HATEOAS paradigm . We went a little ahead and made our existing API more intelligent , we started caching the response links coming back and started to use it when the next request was made from the GUI for that particular user.                                                                                                                      This might sound a very tough idea initially , we too felt it might become a nightmare , but it turned out to be pretty easy once we migrated couple of our API’s.
  • For some of very simple URL’s and also less important one’s (comparatively , like HELP link ) , we went ahead and changed the GUI code . It was easy because such links don’t have many verbs attached to it and we could hard code the mapping of the verbs to the links coming form back-end as they don’t change frequently  .

All our new GUI’s do use SPRING HATEOAS paradigm and REACT-JS as our front end coding framework . We have recently started migrating some of our API’s drastically due to new business requirement and to the surprise our GUI’s are hardly impacted .

Comments are closed.

Blog at WordPress.com.

Up ↑

%d bloggers like this: