[REQUEST FEATURE] custapache24 (custapache too?)
Original Reporter info from Mantis: silvioprog
-
Reporter name: silvioprog
Original Reporter info from Mantis: silvioprog
- Reporter name: silvioprog
Description:
Hello,
It would be interesting to have this unit, because fpapache24 has a dependency with fphttp. With this dependency, I need to do a extra 'init/free' in application:
... begin FreeAndNil(Application); &LtPos;&LtPos;< Ugly! frees the previous TApacheApplication instance Application := TMyApacheModule.Create(nil); Application.ModuleName := ModuleName; Application.HandlerName := HandlerName; Application.SetModuleRecord(DefaultModule); Application.Initialize; end. ...
Steps to reproduce:
mod_project1:
library mod_project1; {$mode objfpc}{$H+} uses {$ifdef unix} cthreads, {$endif} httpd24, fpapache24, myapachemodule, sysutils; const ModuleName = 'mod_project1'; HandlerName = ModuleName; var DefaultModule: Module;{$IFDEF UNIX}public Name ModuleName;{$ENDIF UNIX} exports DefaultModule Name ModuleName; begin FreeAndNil(Application); // &LtPos;&LtPos;< :-/ Ugly, but necessary to use TMyApacheModule instance instead of TApacheApplication Application := TMyApacheModule.Create(nil); Application.ModuleName := ModuleName; Application.HandlerName := HandlerName; Application.SetModuleRecord(DefaultModule); Application.Initialize; end.
myapachemodule:
unit myapachemodule; {$mode objfpc}{$H+} interface uses fpapache24, custweb, HTTPDefs, sysutils; type { TMyApacheModule } TMyApacheModule = class(TApacheApplication) public function InitializeWebHandler: TWebHandler; override; end; { TMyApacheHandler } TMyApacheHandler = class(TApacheHandler) public procedure HandleRequest(ARequest: TRequest; AResponse: TResponse); override; end; implementation { TMyApacheModule } function TMyApacheModule.InitializeWebHandler: TWebHandler; begin Result := TMyApacheHandler.Create(Self); end; { TMyApacheHandler } procedure TMyApacheHandler.HandleRequest(ARequest: TRequest; AResponse: TResponse); begin AResponse.Contents.Text := 'testing it'; end; finalization FreeAndNil(Application); end.
Mantis conversion info:
- Mantis ID: 26301
- Version: 2.6.4
- Fixed in version: 3.1.1
- Fixed in revision: 32943 (#82cfccce)
- Monitored by: » zaher (Zaher Dirkey)
- Target version: 3.0.2