Skip to main content

Encoding Actions on Resources

  • Chapter
  • First Online:
  • 1168 Accesses

Abstract

It is important to understand the role of HTTP and what it brings into the picture. The HTTP’s uniform interface relieves clients from learning fundamentally new ways of handling resources. Everything happens via URLs (these are identifiers and handles of resources at the same time) and HTTP regular methods (see the sidebar “Identifier vs. Handle” later in this chapter for more details about them).

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   49.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Notes

  1. 1.

    The OPTIONS can be used by a client to figure out the affordances regarding a particular resource. The response would be a set of HTTP methods (GET, PUT, etc.). In a Level 3 REST API the server sends this information proactively using hypermedia controls. Therefore, the client isn’t any more motivated to issue OPTIONS, nor in doubt about what is affordable with a resource (you can read more about this HTTP header at http://zacstewart.com/2012/04/14/http-options-method.html ).

  2. 2.

    It is also possible to use the url property of the WebPage, but it is better to be consistent across your APIs. In case you need a self-link from a representation, which isn’t a WebPage per se, then you would need to come up with a new convention. Consistency is only one of the myriad quality attributes of an API (read [3] for a good overview).

  3. 3.

    This is throwaway code, and is using static methods, which aren’t proper for an API. See the exercises at the end of this chapter for more directions on how to refactor it.

  4. 4.

    Read more about the PathVariable annotation in the Spring documentation.

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2016 Ervin Varga

About this chapter

Cite this chapter

Varga, E. (2016). Encoding Actions on Resources. In: Creating Maintainable APIs. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-2196-9_7

Download citation

Publish with us

Policies and ethics