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
-
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).
-
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
- GET
-
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.
-
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:
- When creating or editing a route, select Authentication if the route requires login.
- Choose Authorization rules to restrict access to specific user roles.
- Routes without authentication are publicly accessible.
- Authentication: Ensures only logged-in users can access certain routes.
-
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):
- Select the Module Field you want to filter (e.g., Category, User, Status).
- Choose an Operator (e.g., equals, greater than, less than).
- Enter the Value for filtering (e.g., "Health" category).
- Add multiple conditions if needed (they can be combined with AND/OR logic).
- 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)
- Navigate to the Routes section in your admin panel.
- Click Add New Route.
- Enter the Route Name and URL Path.
- Example:
/blog
– “Displays all blog posts.”
- Example:
- Select Route Type (
Inbound
orOutbound
). - Select HTTP Method(s) the route should respond to (GET, POST, etc.).
- Choose Response Type (
HTML
,JSON
, orXML
). - Configure Authentication and Authorization (if required).
- Save the route.
4. Editing a Route
To update an existing route:
- Go to the Routes list.
- Click Edit next to the route name.
- Update the URL, type, HTTP method, response, or security rules.
- 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
-
Create an Inbound Blog List Route:
- URL:
/blog
- Type: Inbound
- Method: GET
- Response: HTML
- Authentication: None (public)
- URL:
-
Create an Inbound Blog Details Route:
- URL:
/blog/{id}
- Type: Inbound
- Method: GET
- Response: HTML
- Authentication: None (public)
- URL:
-
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
- URL:
Next Steps: After mastering routes, learn about Hooks & Actions to trigger custom logic when routes or modules are used.