Request processing pipeline
This page concerns detailed exaplanation of request pipeline.
PROBABLY YOU WILL NOT NEED THAT unless you are doing something deep inside the system or changing default behavior.
In simplified form, on each HTTP request, firstly an authentication is done then either a controller set through rewrites is executed or a web-page is rendered, but there are lots of things under the hood which are done.
HTTP request execution
Each HTTP request is processed in the following sequence:
- The rr=new LNRR (Request-Response) context is created, which is responsible for all request and response data
- The corresponding site config is searched in the folder lattenoir/config/sites-enabled/
- If the site is not found, an HTML error message is displayed, END OF PROCESSING
- rr.set_site(), server.init_site(), server.configure() are launched, connecting to the database, loading the required JS files, etc.
- If a configuration error occurs, an HTML error message is output, END OF PROCESSING
- The authentication engine (LNSession) starts
- If do-login=1 is specified in the HTTP parameters, and login and password are also specified, then authentication occurs using login and password, and a cookie SID with the session is returned
- If do-logoff=1 is specified in the HTTP parameters, the session is removed from the database and an empty cookie is returned
- If a cookie SID is sent, then cookie authentication occurs
- In case of successful authentication by any method, the variables rr.uid=Integer, rr.user=Object, rr.roles=Object, rr.roles_by_id=Object are filled
- rr.do_rewrites() is launched, performing all URL substitutions.
- Redirects the page /index/ to the page /mobile/index/ if the user came from a mobile device and redirection is activated in the site config
- Applies custom_rewriter(rr) if it is specified in the site config
- Assigns an anonymous cookie if the user is not authenticated and enabled in the site config
- Executes standard rewriter (LNRewriter)
- If the resulting URL === undefined, then rr.prerun_ouput is returned as the result of the HTTP request, END OF PROCESSING
- If URL!==undefined, Run rr.process_page() processing the URL depending on its template
- If process_page() throws an exception, then rollback() is done for the database connection and the error text is returned
- commit() is done for the current database connection
Processing rr.process_page()
- If URL.match(/-preview/), the image scaling generator rr.mk_preview() is run, returning the image
- If URL.match(/-state/), the alternative image scaling generator rr.mkpreviewState() is run, returning the image
- If URL.match(/^\/admin(_popup|)-(\w+)(-(\w+)|)\/$/), the admin page generator based on the controller is started, rr.process_admin_page()
- If URL.match(/^\/admin\/$/), the admin page generator is run, returning the result, rr.process_admin_page()
- If URL.match(/^\/client-side-views\/$/), the template folder compiler is run to use the template engine on the client, the result is returned
- If URL.match(/^\/ajaj-auth\/$/), the password authenticator is launched, a JSON result is returned about the authentication results
- The standard page generator rr.process_regular_page() is launched and the result is returned
Processing rr.process_regular_page()
- The page is taken from the Tpages table, where Tpages.alias=URL
- If the page is not found, an HTML error message is displayed, END OF PROCESSING
- Access rights are checked
- If hide_anon is specified and the user is not authenticated, an HTML error message is output, END OF PROCESSING
- If hide_reg is specified and the user is authenticated, an HTML error message is output, END OF PROCESSING
- If role_id is specified and the user is not authenticated or does not have the specified access rights, an HTML error message is output, END OF PROCESSING
- All page blocks are selected from the database based on the specified page template
- Prerun is run for this page (if specified), the result is stored in rr.prerun_output
- If prerun throws an exception (throw), then rollback() is done for the database connection, and the error text is stored in prerun_output
- If the ajaj parameter is specified in HTTP POST/GET, then
- If the is-iframe parameter is also specified in the HTTP POST/GET, then the "system/iframe_response" template is returned to call a function in the client browser to pass data from the nested iframe to the main document frame.
- Returns rr.prerun_output || rr.output
- All blocks of the page for which the compilation flag is specified are compiled
- The page template is compiled and the result is returned