In this chapter, we first looked into what middleware is and how middleware processes a request and response. We then explored the middleware code, with a few practical examples. After that, we saw how to chain many middleware, one after the other. A package such as alice can be used for intuitive chaining. A package from the Gorilla toolkit, gorilla/handlers, provides various middleware for logging, compression, and Cross-Origin Resource Sharing (CORS).
Next, we learned what an RPC is, and how an RPC server and client can be built. After that, we explained what a JSON-RPC is, and we saw how to create a JSON-RPC using the Gorilla toolkit. We introduced many third-party packages for middleware and RPC along the way.
In the next chapter, we are going to explore a few famous web frameworks that further simplify REST API creation.