In the current framework version, the routing of HTTP requests to the app backend is not configurable and works according to fixed rules (which can, however, be overridden inside an individual app).
The common backend of all apps is accessible within address space
http://[domain_name]/[webasyst_root_path]/webasyst/*
. The backend of each app is accessible within
address space http://[domain_name]/[webasyst_root_path]/webasyst/[app_id]/*
,
where APP_ID is the app identifier.
Relationship between the request URL and the class and method called for its processing is defined by the front controller class. By default (if
an app does not have its own front controller) system class waFrontController
is used, which works in accordance with the rules
detailed below.
System front controller operating logic
App backend is accessible via URLs of the form
/webasyst/[app_id]/[?module=[module]][&action=[action]][&extra_parameters]
. System
front controller waFrontController
executes a specific module and an action of the requested app based on the values of parameters
module and action retrieved from the GET request. Both parameters (module and action) are optional; if they are not
specified, default class and method selection rules are applied. The default value for parameter module is backend
. System front
controller waFrontController
searches a class and a method according to the rules described in section
Naming rules and recommendations.
Examples of relationship between request URLs and module methods
Below are shown examples of the module/method search algorithm operation for a sample app with identifier myblog
:
/webasyst/myblog/
myblogBackendController->execute()
myblogBackendAction->execute()
myblogBackendActions->defautAction()
/webasyst/myblog/?module=mail
myblogMailController->execute()
myblogMailAction->execute()
myblogMailActions->defautAction()
/webasyst/myblog/?module=mail&action=test
myblogMailTestController->execute()
myblogMailTestAction->execute()
myblogMailActions->testAction()
The system searches for a class and a method in the order shown above and executes the first found variant.
Overriding backend routing rules
If the routing rules of your app backend require modification of the default routing logic, you need to override the front controller for your
app. To do so, create a new class extending base class waFrontController
. Implement the request routing logic in its method
dispatch
.
Then add the following line to file wa-apps/[app_id]/lib/config/factories.php
:
'front_controller' => 'your_class_name'
For example, if your app's front controller class name is myblogFrontController
, then file factories.php
should have
the following contents:
<?php return [ ... 'front_controller' => 'myblogFrontController', ];