Course Overview
Locked video preview

Watch for free

Create a free account to watch this video.

MVC & Application structure

Router and routes

Here is a summary of the video transcript:

  • Routing in MVC Architecture
    The router maps incoming HTTP requests (GET, POST, PUT, DELETE) to specific controller functions. It acts as the intermediary between request paths and the appropriate controller logic.

  • Centralized Route Definitions
    A dedicated routes package is created to define application paths in a single location. This prevents hard-coded strings and ensures consistency when updating routes.

  • Dynamic URL Parameters
    Routes such as /articles/:id use parameters to extract values (e.g., article IDs) from the URL. These parameters are programmatically replaced when generating links in views.

  • Refactoring Views to Use Route Constants
    Hard-coded paths in views are replaced with references to centralized route variables. This improves maintainability and reduces duplication.

  • Router Package Setup with Echo
    A router package is implemented to configure the Echo framework. It defines a router struct holding the Echo instance and registers routes to their corresponding controllers.

  • Server Integration
    The router returns a configured handler that is later used to initialize and run the server. This structure supports future expansion, including middleware and logging configuration.