June 2017
Intermediate to advanced
400 pages
10h 32m
English
This code demonstrates how to hide logic such as authentication, token refresh, and more using the Transport interface. It also demonstrates exposing an API call via a method. Had we been implementing against something like a user API, we would expect methods like:
type API interface{ GetUsers() (Users, error) CreateUser(User) error UpdateUser(User) error DeleteUser(User)}
If you've read Chapter 5, All about Databases and Storage, this may look similar to the recipe. This composition through interfaces, especially common interfaces like the RoundTripper interface, provide a lot of flexibility for writing APIs. In addition, it may be useful to write a top-level interface as we did earlier and pass the interface around instead ...
Read now
Unlock full access