-
Book Overview & Buying
-
Table Of Contents
Build Your Own Web Framework in Elixir
By :
In this chapter, we first defined the desired DSL for our router module. We also understood why we use metaprogramming here, similar to the previous chapter.
Then, we took a look at the state of our router before this chapter and identified the lines that could be moved out of the router to the DSL. We started to build our DSL by moving all the plug calls to the __using__/1 macro in Goldcrest.Router. We then found a way to add a generic match clause to get a default 404 response. We made the use statement dynamic by allowing it to pass options to the Plug.Parsers call as part of the use call.
We then worked on adding reflections and introspective features to the router DSL, similar to what we did in Chapter 9 for controllers and views. We also defined helper functions and helper modules that allow us to reference a path by using a controller and action, similar to Phoenix. Finally, we added test helpers along with an example test for a router.
This concludes our minimal...