[Lazarus] Changes to fpWeb...
Michael Van Canneyt
michael at freepascal.org
Sat Jan 14 16:48:54 CET 2017
On Sat, 14 Jan 2017, Marcos Douglas B. Santos via Lazarus wrote:
> On Fri, Jan 13, 2017 at 8:36 PM, Michael Van Canneyt via Lazarus
> <lazarus at lists.lazarus-ide.org> wrote:
>>
>> Hello,
>>
>> I have committed a serious change to the way fpweb handles requests.
>>
>> Especially routing of requests was changed.
>>
>> [...]
>
> For me, this is great news.
> I'm feeling we've started to go ahead writing complex Web systems
> using Object Pascal.
> Thanks Michael and all those who have been contributing for these new features.
Well, after working some years in web environments, I felt I had enough
experience to diverge from what Delphi originally did :)
Now things become really simple:
uses fpcgi, httpdefs, httproute;
procedure DoHello(ARequest:TRequest; AResponse : TResponse);
begin
AResponse.Content:='<html><body><h1>Hello,World!</h1></body></html>'
end;
begin
HTTPRouter.RegisterRoute('*', at DoHello);
Application.Initialize;
Application.Run;
end.
The only way to get it even more concise would be with anonymous functions.
And by changing fpcgi to fpfastcgi or fphttpapp, you can switch between all
kinds of web enabled application. Can't get more simple than that, I think.
Michael.
More information about the Lazarus
mailing list