I'm using the TWebModule component to write a web server application with Delphi. Clicking on the Actions property of the TWebModule a new action can be defined and a "OnAction" event handler created. For example:
procedure TMainWeb.MyAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
Response.Content := '<html><body>myvariable: '+request.queryfields.values['myvariable']+</body></html>';
end;
I have noticed non-parametered procedures can be called which have access to the TWebModule's Request, Response, and Handled parameters. For instance, I have successfully used the following instead of explicitly created action handlers:
procedure TMainWeb.WebModuleBeforeDispatch(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
if Pos('myaction.html',request.url)>0 then
DoMyAction;
end;
procedure TMainWeb.DoMyAction;
begin
Response.Content := '<html><body>myvariable: '+request.queryfields.values['myvariable']+</body></html>';
end;
Can I always be assured the references to Sender, Request, Response, and Handled I make in DoMyAction are the "correct" ones?