Routing, Controllers, and Plugs
Define routes, implement controller actions, and use Plugs to build modular and reusable request pipelines.
Mapping Your Web Requests
Welcome to routing in Phoenix! Think of routing as your application's traffic controller. When a user visits a URL, the router determines which part of your code should handle that request.
It's how Phoenix connects an incoming web address (like /users) to a specific function in your application.
The `router.ex` File
In Phoenix, all your routes are defined in the lib/my_app_web/router.ex file. This file uses special macros to declare how different HTTP methods (GET, POST, PUT, DELETE) map to your application's logic.
You'll often see routes grouped into scopes and processed by pipelines, which apply common behaviors.
All lessons in this course
- Phoenix Project Setup and Structure
- Routing, Controllers, and Plugs
- Views, Templates, and LiveView Basics
- Real-Time Features with Phoenix Channels