Wrapping handler functions

One of the most valuable patterns to learn when building web services and websites in Go is one we already utilized in Chapter 2, Adding Authentication, where we decorated http.Handler types by wrapping them with other http.Handler types. For our RESTful API, we are going to apply this same technique to http.HandlerFunc functions, to deliver an extremely powerful way of modularizing our code without breaking the standard func(w http.ResponseWriter, r *http.Request) interface.

API key

Most web APIs require clients to register an API key for their application, which they are asked to send along with every request. Such keys have many purposes, ranging from simply identifying which app the requests are coming from to addressing ...

Get Go: Building Web Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.