<p><span>Discover the secrets of building high-performing and scalable web applications with clean code using Elixir's metaprogramming</span></p><p><span>Purchase of the print or Kindle book includes a free PDF eBook</span></p><h4><span>Key Features</span></h4><ul><li><span><span>Explore the various
Build Your Own Web Framework in Elixir: Develop lightning-fast web applications using Phoenix and metaprogramming
β Scribed by Aditya Iyengar
- Publisher
- Packt Publishing
- Year
- 2023
- Tongue
- English
- Leaves
- 274
- Category
- Library
No coin nor oath required. For personal study only.
β¦ Synopsis
Discover the secrets of building high-performing and scalable web applications with clean code using Elixir's metaprogramming
Purchase of the print or Kindle book includes a free PDF eBook
Key Features
- Explore the various web servers available to build robust web applications
- Leverage Elixir's powerful Plug module to build a request-response pipeline
- Explore advanced techniques of Elixir to create Domain-Specific languages and build scalable, maintainable web products
Book Description
Elixir's functional nature and metaprogramming capabilities make it an ideal language for building web frameworks, with Phoenix being the most ubiquitous framework in the Elixir ecosystem and a popular choice for companies seeking scalable web-based products. With an ever-increasing demand for Elixir engineers, developers can accelerate their careers by learning Elixir and the Phoenix web framework.
With Build Your Own Web Framework in Elixir, you'll start by exploring the fundamental concepts of web development using Elixir. You'll learn how to build a robust web server and create a router to direct incoming requests to the correct controller. Then, you'll learn to dispatch requests to controllers to respond with clean, semantic HTML, and explore the power of Domain-Specific Languages (DSL) and metaprogramming in Elixir. You'll develop a deep understanding of Elixir's unique syntax and semantics, allowing you to optimize your code for performance and maintainability. Finally, you'll discover how to effectively test each component of your application for accuracy and performance.
By the end of this book, you'll have a thorough understanding of how Elixir components are implemented within Phoenix, and how to leverage its powerful features to build robust web applications.
What you will learn
- Get a comprehensive understanding of the Phoenix framework built on Elixir
- Use metaprogramming to optimize your Elixir code and create high-performance web applications
- Explore web development fundamentals including the principles of HTTP and HTML
- Employ Elixir's templating engine to dispatch requests to a controller and respond with dynamically generated HTML
- Improve the scalability and responsiveness of your web server by using OTP constructs
- Streamline your routing logic using error handling
Who this book is for
This book is for web developers seeking to deepen their understanding of Elixir's role in the Phoenix framework. Basic familiarity with Elixir is a must.
Table of Contents
- Introducing the Cowboy Web Server
- Building an HTTP Server in Elixir
- Defining Web Application Specifications Using Plug
- Working with Controllers
- Adding Controller Plugs and Action Fallback
- Working with HTML and Embedded Elixir
- Working with Views
- Metaprogramming- Code That Writes Code
- Controller and View DSL
- Building the Router DSL
β¦ Table of Contents
Cover
Title Page
Copyright and Credits
Dedications
Foreword
Contributors
Table of Contents
Preface
Part 1: Web Server Fundamentals
Chapter 1: Introducing the Cowboy Web Server
Technical requirements
What is a web server?
Exploring the client-server architecture
Understanding HTTP
Understanding Cowboyβs architecture
Building a web application using Cowboy
Creating a new Mix project
Adding a handler and router to Cowboy
Supervising the web server
Adding routes with bindings
Validating HTTP methods
Responding with HTML files
Testing the web server with ExUnit
Summary
Exercises
Chapter 2: Building an HTTP Server in Elixir
Technical requirements
Listening over a TCP socket using :gen_tcp
Responding over a TCP socket using :gen_tcp
Writing an HTTP server package
Defining an HTTP response struct
Validating whether a responder is configured
Creating responder behavior
Testing the HTTP server
Running the HTTP server with a sample application
Adding concurrency to the server
Bonus β starting a detached HTTP server
Summary
Exercise
Part 2: Router, Controller, and View
Chapter 3: Defining Web Application Specifications Using Plug
Technical requirements
What is Plug?
Representing the state of the connection with the Plug.Conn struct
Defining a plug
Understanding Plug.Router
Plugifying our HTTP server
Summary
Chapter 4: Working with Controllers
Technical requirements
What are controllers?
Controllers in Phoenix
Building a controller interface
Integration with web servers
Understanding redirects
Testing the controller
Summary
Exercises
Chapter 5: Adding Controller Plugs and Action Fallback
Technical requirements
Plug pipeline in controllers
Understanding the Plug.Builder module
Building the controller pipeline
Implementing action fallback
Summary
Chapter 6: Working with HTML and Embedded Elixir
Technical requirements
Understanding and exploring embedded elixir
Defining functions dynamically in a module
Compiling a template with a module
Working with EEx options
Using EEx Smart Engine
Understanding custom markers
Building a custom EEx engine
Responding with html.eex files
Testing our templates
Testing with Floki
Summary
Chapter 7: Working with Views
Technical requirements
What is a view?
Views in Phoenix
Building a view interface
Passing helper functions to templates
Taking Goldcrest for a spin
Defining a store
The index action
The create action
The delete action
Summary
Exercises
Part 3: DSL Design
Chapter 8: Metaprogramming β Code That Writes Code
Technical requirements
The pros and cons of metaprogramming
When to use metaprogramming
Metaprogramming in Elixir
Understanding quoted literals
Evaluating quoted literals
The hygienic evaluation of quotes
Adding dynamic behavior to quotes
Code injection using evaluation
Code injection using macros
The using macro
Compile-time callbacks
Before compile
After compile
On-definition
Building a music DSL in Elixir
Writing the implementation
Building the interface layer
Testing the interface
Writing integration tests
Testing sequence
Testing note and embed_notes
Testing restrictions
Adding DSL test helpers
Summary
Exercises
Chapter 9: Controller and View DSL
Technical requirements
Why use metaprogramming here?
DSL design
Building the controller DSL
Adding reflections
Reflective plugs
Extracting response helpers
Building the View DSL
Building a web app using the DSLs
Creating test helpers for ease of testing and debugging
Summary
Exercises
Chapter 10: Building the Router DSL
Technical requirements
Why use metaprogramming here?
DSL design
Building the router DSL
Adding reflections
Reflective routes
Building router helpers
Creating test helpers
Summary
Exercises
Index
About Packt
π SIMILAR VOLUMES
<p><span>Discover the secrets of building high-performing and scalable web applications with clean code using Elixir's metaprogramming</span></p><p><span>Purchase of the print or Kindle book includes a free PDF eBook</span></p><h4><span>Key Features</span></h4><ul><li><span><span>Explore the various
<p><span>Discover the secrets of building high-performing and scalable web applications with clean code using Elixir's metaprogramming</span></p><p><span>Purchase of the print or Kindle book includes a free PDF eBook</span></p><h4><span>Key Features</span></h4><ul><li><span><span>Explore the various
Discover the secrets of building high-performing and scalable web applications with clean code using Elixir's metaprogramming Key Features Explore the various web servers available to build robust web applications Leverage Elixir's powerful Plug module to build a request-response pipeline Expl
<span>Flask can quickly help you grow a tech project like a web app as a micro-framework. If you want to make a small app that can grow rapidly and in ways you havenβt thought of, itβs a good option. It is easy to use and has few dependencies, so it works well even as it gets bigger and bigger.<br><
<span>Django is exciting if you are interested in building websites. Django is a framework for making websites. It saves you a lot of time and makes building websites easier and more fun. Django makes it easy to build and maintain high-quality web applications.<br>Web development is a creative journ