Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Hypermedia-Driven RESTful APIs

Hypermedia-Driven RESTful APIs

B0e9230af37f3a883c88d3f11c00e174?s=128

Christoph Strobl

May 25, 2016
Tweet

Transcript

  1. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ > Hypermedia-Driven RESTful APIs > Christoph Strobl | @stroblchristoph > Pivotal Software, Inc.
  2. 2

  3. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ > > REST?
  4. 4 POST = Create, GET = Read,… Client-Server, Stateless, Cacheable

    > Representational State Transfer > uses: HTTP for CRUD > requires: Architecture Constraints Uniform Interface
  5. 5 image source: http://petstore.swagger.io

  6. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ > > Hypermedia?
  7. Hypermedia Presentation of data and navigation controls! at the same

    time
  8. HATEOAS 8 Media Types describe resources. Actions are executed by

    following links. Response reflects state. Clients explore the API. Hypermedia as the Engine of Application State
  9. HAL 9 Resource Links Embedded Resource State Name Target Hypertext

    Application Language
  10. ALPS 10 Closes the gap between! ! state and transition.

    Descriptors semantic data safe GET unsafe POST idempotent PUT/DELTE Application Level Profile
 Semantics
  11. JSON Schema 11 Describes your JSON data

  12. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software,

    Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ > > Demo?
  13. Spring Data REST 13 @SpringBootApplication public class StoreApp { !

    public static void main(String[] args) { SpringApplication.run(StoreApp.class, args); } ! interface StoreRepository extends PagingAndSortingRepository<Store, String> { ! ! } } Page<Store> findByAddressLocationNear(Point location, Distance distance, Pageable pageable); @RestResource(rel = "by-location") <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-rest</artifactId>
  14. 14 Repository Resource Relation Link IDs URIs @Version ETags @LastModified

    Date Last-Modified What it does
  15. Let’s try this local… 15 <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> >

    mvn clean spring-boot:run
  16. None
  17. I am completely operational.! ! All my circuits ! are

    functioning perfectly. Thank you! image source: HAL 9000 - Space Odyssey wallpaper
 http://www.wallconvert.com/
  18. Resources (alphabetical) § alps.io/spec/ § json-schema.org § projects.spring.io/spring-boot § projects.spring.io/spring-data

    § stateless.co/hal_specification § swagger.io 18