What happens when you type a Phoenix URL into your address bar and press "Enter"?
September 26, 2024
#development #elixir #phoenix #reading-list
🔗 What happens when you type a Phoenix URL into your address bar and press "Enter"?
arrowsmithlabs.com
Here's a classic question that I've asked and been asked in many job interviews: "What happens when you type a URL into your browser's address bar and hit Enter?"
A good answer includes a basic explanation of DNS, networking and the structure of an HTTP request and response. But if it was a Phoenix job I might ask a follow-up: "what if the page is rendered by a Phoenix app?"
In order to answer this well, you need a broad understanding of the Phoenix stack:
%Plug.Conn{}
,Endpoint
, theRouter
, plugs, pipelines, controllers and views. Then if the page is a LiveView, you also need to know about websockets and the LiveView lifecycle, including quirks such as thatmount/3
is called twice. So it's a good question to test your knowledge - and studying the answer is a great way to deepen your understanding of Phoenix.In this two-part series, I'll give the high-level overview. First I'll explain how Phoenix renders a static HTML page for routes that are served by a controller. Then in part 2 (coming soon), I'll explain what additionally happens if the route is served by a LiveView.
continue reading on arrowsmithlabs.com
⚠️ This post links to an external website. ⚠️
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.