hi everyone!
I wanna share with you the best http framework for Pascal! (Delphi, Lazarus and others)
https://github.com/OpenSourceCommunityBrasil/PascalRALThere's also a dedicated sample repository with lots of examples:
https://github.com/OpenSourceCommunityBrasil/PascalRAL-SamplesThis is a quick simple example of a working webserver:
program RALWebExample;
uses
Classes, SysUtils, System.IOUtils,
// Choose here the engine of the server
RALSynopseServer,
//RALIndyServer,
//RALSaguiServer,
RALServer, RALWebModule,
// routing unit
Web.Routes in 'src/web.routes.pas';
var
FServer: TRALServer;
FWebModule: TRALWebModule;
begin
// Change the engine of the server here:
FServer := TRALSynopseServer.Create(nil);
//FServer := TRALIndyServer.Create(nil);
//FServer := TRALSaguiServer.Create(nil);
FWebModule := TRALWebModule.Create(nil);
try
FWebModule.Server := FServer;
{
Defining the root path where the webfiles should be stored. We use TPath.Combine
here for easy compatibility between Windows and Linux servers, since Windows
uses '/' for folders and Linux uses '\'. It's easy to mix those so TPath solves
that
}
FWebModule.DocumentRoot := TPath.Combine(ExtractFileDir(ParamStr(0)), 'web');
// adding routes to the server from unit Web.Routes:
RegisterWebRoutes(FWebModule);
FServer.Port := 8000; // 8000 is the default port if none is assigned.
FServer.Start;
WriteLn('RALServer running on Port ' + FServer.Port.ToString);
WriteLn('Press any key to finish');
ReadLn;
finally
FServer.Stop;
FreeAndNil(FWebModule);
FreeAndNil(FServer);
end;
end.
We aimed for speed, simplicity and flexibility in this project as well as being independent of any specific http component, like indy. We also support RAD and DBWare in the project with plans on improving the speed in future updates.
The framework has been in development for 3 years but only last year that we managed to make it stable and resilient enough to be publicly available. It's currently in release candidate and we'll launch the first stable version before adding even more features.
Since practically every HTTP framework out there is depedant on indy and are slow as a slime because indy is slow, we aim to kill that handicap and use the fastest possible data engines available to make Pascal API servers as competent as other languages' server frameworks.
We also added support to FPC-Unleashed, currently available under the "dev" branch.
We look forward to hear your feedback, any issues can be reported in the repository and we welcome any PRs with improvements to the code.
I'll answer any questions or doubts you might have too, just lemme know.