5
Adding Controller Plugs and Action Fallback
In the last chapter, we built a framework to write a controller and wrapped it inside the Goldcrest.Controller module. In this chapter, we will learn about extending the functionality of our controllers by intercepting an incoming request and calling specific plugs on it based on the controller’s definition before letting the controller’s actions handle that request. This will give developers the means to add better control of the request flow while keeping their controller code simple and digestible. We will learn how to use the Plug.Builder module to build a pipeline of plugs in a controller. We will then learn how to apply a pipeline of plugs to an action and how to define a fallback controller ...
Get Build Your Own Web Framework in Elixir 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.