63

Building richer hypermedia with Spring HATEOAS

 6 years ago
source link: https://spring.io/blog/2018/01/12/building-richer-hypermedia-with-spring-hateoas
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
<div class="paragraph"> <p>Greetings Spring community,</p> </div><div class="paragraph"> <p>As <a href="https://twitter.com/gregturn/status/935853433931943936">previously announced</a>, we have released a new <strong>Affordances API</strong> in 1.0.0.BUILD-SNAPSHOT. In this blog post, we’ll take a peek at exactly what this feature lets you do.</p> </div><div class="sect1"> <h2 id="history-of-affordances"><a class="anchor" href="#history-of-affordances"></a>History of Affordances</h2> <div class="sectionbody"> <div class="paragraph"> <p>For starters, what is an <strong>affordance</strong>? Doing a little archeology, Mike Admundsen, a REST advocate, has <a href="http://amundsen.com/blog/archives/1109">an article detailing the word’s origins</a>, going back at least to 1986:</p> </div> <div class="verseblock"> <pre class="content">The affordances of the environment are what it offers …​ what it provides or furnishes, either for good or ill. The verb 'to afford' is found in the dictionary, but the noun 'affordance' is not. I have made it up (page 126).</pre> <div class="attribution"> — The Ecological Approach to Visual Perception (Gibson) </div> </div> <div class="paragraph"> <p>It then appeared in a psychology paper in 1988:</p> </div> <div class="verseblock"> <pre class="content">…​the term affordance refers to the perceived and actual properties of the thing, primarily those fundamental properties that determine just how the thing could possibly be used. (pg 9)</pre> <div class="attribution"> — The Design|Psychology of Everyday Things (Norman) </div> </div> <div class="paragraph"> <p>Finally, it can be found in none other than one of Roy Fielding’s presentations on hypermedia in 2008:</p> </div> <div class="verseblock"> <pre class="content">When I say Hypertext, I mean the simultaneous presentation of information and controls such that the information becomes the affordance through which the user obtains choices and selects actions (slide #50).</pre> <div class="attribution"> — Slide presention on REST (Fielding) </div> </div> <div class="paragraph"> <p>In all these situations, "affordance" refers to the available actions provided by the surrounding environment. In the context of REST, these are actions detailed by the hypermedia.</p> </div> <div class="paragraph"> <p>In the past, when people moved away from SOAP and its action-based tactics, they have struggled to document their APIs, many unaware that Roy Fielding built hypermedia into REST for this very purpose. By including data along with the controls to not just find related data, but to also use the data is key.</p> </div> <div class="paragraph"> <p>With a HAL document, clients are provided very simple affordances. The links are shown but nothing else about them. What you can do with the links and what it takes to interact with them is not detailed.</p> </div> </div> </div>

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK