Cookies

This website uses cookies to ensure you get the best experience on our website.

Guide: Understanding and Creating Routes

Routes define how your website responds to different URL requests. They determine what content or functionality is displayed when a user visits a specific URL.

This guide will teach you how to create and manage routes, configure their type, HTTP method, response, and security, step by step.


1. What is a Route?

A route connects a URL path to a specific action or page on your website. For example:

  • /blog → Displays all blog posts
  • /blog/{id} → Displays a single blog post
  • /contact → Displays the contact form

Routes make your website dynamic and navigable.


2. Key Features of a Route

  1. Route Type
    Your platform supports two route types:

    • Inbound: Handles requests coming into the system (e.g., user visits a page or API call).
    • Outbound: Handles responses leaving the system to external services or integrations (e.g., webhook notifications, API responses).

  2. HTTP Method
    Each route responds to specific HTTP methods, determining the type of request it accepts:

    Method Description
    GET Retrieves data or displays a page
    POST Submits data to the server
    PUT Updates existing data
    PATCH Updates partial data
    DELETE Deletes data

    Example:
    A Blog module route:

    • GET /blog → List all posts
    • GET /blog/{id} → View a single post
    • POST /blog → Create a new post

  3. Response Type
    Routes return content in specific formats:

    • HTML: Standard web page displayed in a browser.
    • JSON: Data response for API endpoints.
    • XML: Structured data for integrations or external systems.

  4. Authentication and Authorization
    Routes can include security rules to control access:

    • Authentication: Ensures only logged-in users can access certain routes.
      • Example: Only registered users can view their profile.
    • Authorization: Ensures that only users with specific permissions or roles can perform actions.
      • Example: Only admins can delete blog posts.

    How it works for users:

    1. When creating or editing a route, select Authentication if the route requires login.
    2. Choose Authorization rules to restrict access to specific user roles.
    3. Routes without authentication are publicly accessible.

  5. Route Conditions (Data Filtering)
    Route conditions allow you to filter the data that a route returns, based on specific criteria. This ensures users only see the content relevant to them.

    Examples of Conditions:

    • Show blog posts only from a specific category.
    • Display orders for a logged-in user only.
    • Filter products by price or availability.

    How to add conditions (Step-by-Step):

    1. Select the Module Field you want to filter (e.g., Category, User, Status).
    2. Choose an Operator (e.g., equals, greater than, less than).
    3. Enter the Value for filtering (e.g., "Health" category).
    4. Add multiple conditions if needed (they can be combined with AND/OR logic).
    5. Save the route to apply the conditions.

    Example Workflow:

    • Route: /blog (Inbound, GET, HTML)
    • Condition: Category = "Technology"
    • Result: Only blog posts in the Technology category are displayed.

Tip: Use conditions to make routes dynamic and personalized for users, without creating separate routes for each scenario.


3. How to Create a Route (Step-by-Step)

  1. Navigate to the Routes section in your admin panel.
  2. Click Add New Route.
  3. Enter the Route Name and URL Path.
    • Example: /blog – “Displays all blog posts.”
  4. Select Route Type (Inbound or Outbound).
  5. Select HTTP Method(s) the route should respond to (GET, POST, etc.).
  6. Choose Response Type (HTML, JSON, or XML).
  7. Configure Authentication and Authorization (if required).
  8. Save the route.

4. Editing a Route

To update an existing route:

  1. Go to the Routes list.
  2. Click Edit next to the route name.
  3. Update the URL, type, HTTP method, response, or security rules.
  4. Save changes.

Tip: Always test routes after editing to ensure they respond correctly and follow security rules.


5. Best Practices

  • Descriptive URL Paths: Use clear and readable paths (e.g., /blog/new-post).
  • Use the Correct HTTP Method: Ensure the method matches the action type (GET for read, POST for create, etc.).
  • Secure Routes: Protect sensitive routes with authentication and authorization.
  • Test Responses: Check that each route returns the expected content or data.
  • Organize Routes: Group related routes together for easier management.

6. Example Workflow

  1. Create an Inbound Blog List Route:

    • URL: /blog
    • Type: Inbound
    • Method: GET
    • Response: HTML
    • Authentication: None (public)
  2. Create an Inbound Blog Details Route:

    • URL: /blog/{id}
    • Type: Inbound
    • Method: GET
    • Response: HTML
    • Authentication: None (public)
  3. Create an Outbound API Route for Blog Creation:

    • URL: /api/blog
    • Type: Outbound
    • Method: POST
    • Response: JSON
    • Authentication: Required (logged-in users)
    • Authorization: Editor or Admin only

Next Steps: After mastering routes, learn about Hooks & Actions to trigger custom logic when routes or modules are used.