Appendix A. Using HTTP as the Network Protocol
In this appendix we will learn about
- The benefits and features of Http which has become the most common network protocol used for microservices today. Note: although our examples will be of Http based API, the ideas in this book are about good design, and are applicable to whatever network protocol you decide to use
- Http resources and methods, which we will use to define our API
- Safety, Idempotency, and caching in Http APIs
- How to deal with API Versioning
This section is a quick review of HTTP protocol, as it applies to microservice API.
Firstly, HTTP is built around the underlying concept of a resource, and a method, which is an action performed on a resource. HTTP gives us nouns and verbs – the nouns are the resource, and the verbs are the methods.
A.1 HTTP Resource
Resources are basically anything that we can interact with on the web – documents, files, and pretty much anything else we can use on the internet. Resources are identified by a Uniform Resource Identifier (URI), which is a way to uniquely identify every resource in the web.
A unique id for every resource in the world – cool, right?
There are different types of URIs, and we are specifically interested in Uniform Resource Locators (URLs), which not only know the name of the resource, but where it is, and how to get to it. I’m sure you know all about URLs. Just as a reminder, they have: