⭐ Star us on GitHub — it motivates us a lot!
In short, Daraja enables Object Pascal developers to write well-structured HTTP server applications.
Daraja is a compact and flexible HTTP server application framework for Object Pascal, based on the HTTP server included in Indy - Internet Direct. The framework uses URL patterns to match requests to your resource handler code, and optional request filtering for pre- and post-processing. It enables developers to create well-structured HTTP server applications, written with 100% open source code.
Prerequisites
The minimum requirements are:
- Delphi 2009 or higher or
- Lazarus 3.x / Free Pascal 3.2.x
- Indy - Internet Direct 10.6.2 or 10.6.3
Optional requirements for some code examples and logging:
IDE configuration guide
To make Daraja HTTP Framework and Internet Direct (Indy) available for a project,
- add the Daraja HTTP Framework
<Install>/source
folder to the project search path - add the folders
<Indy>/Lib/Core
,<Indy>/Lib/System
and<Indy>/Lib/Protocols
to the project search path
A simple "Hello, World!" application.
A Daraja Web Component defines the request handling and response building, but it does not specifiy the actual location (HTTP address) of a resource.
The web component in this example handles HTTP GET requests by overriding the OnGet method. The method sets the response content text and content type.
THelloWorldResource = class(TdjWebComponent)
public
procedure OnGet(Request: TdjRequest; Response: TdjResponse); override;
end;
procedure THelloWorldResource.OnGet(Request: TdjRequest; Response: TdjResponse);
begin
Response.ContentText := 'Hello, World!';
Response.ContentType := 'text/plain';
end;
procedure Demo;
var
Server: TdjServer;
Context: TdjWebAppContext;
begin
Server := TdjServer.Create(80);
try
Context := TdjWebAppContext.Create('demo');
Context.Add(THelloWorldResource, '/hello.txt');
Server.Add(Context);
Server.Start;
WriteLn('Server is running, please open http://127.0.0.1/demo/hello.txt');
WriteLn('Hit enter to terminate.');
ReadLn;
finally
Server.Free;
end;
end;
Tested with curl:
curl -i http://127.0.0.1/demo/hello.txt
HTTP/1.1 200 OK
Connection: keep-alive
Content-Type: text/plain; charset=ISO-8859-1
Content-Length: 13
Date: Wed, 22 Jan 2025 19:07:14 GMT
Hello, World!
Flowchart diagram
flowchart TD
A[TdjServer] -->|Receive request| B(Locate TdjWebcomponent)
B --> C{Invoke HTTP method}
C -->|**GET**| D[**run OnGet**]
C -->|POST| E[run OnPost]
C -->|PUT| F[run OnPut]
https://michaeljustin.github.io/daraja-framework/
https://www.habarisoft.com/daraja_framework/3.0.3/docs/DarajaFrameworkGettingStarted.pdf
Daraja HTTP Framework is dual licensed under the GNU Affero General Public License and a commercial license. The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software.
Can I use it in my commercial Project?
Yes, if you open source your whole project (thus also AGPL it) otherwise no.Is it enough to ship the licence texts or do I need to ship the source code (from Daraja) too?
You have to supply the whole sourcecode of everything - but a download link should suffice.Do I need to mention the use of Daraja inside my program (like a info message or something)?
No.The commercial license can be obtained from https://www.habarisoft.com/daraja_framework.html
This software uses the following open source packages:
For example code, unit testing, and documentation, it uses the following open source packages:
- JsonDataObjects for example code
- Log4D for logging
- DUnit and FPCUnit for unit testing
- Doxygen Doxygen is a widely-used documentation generator tool in software development
- pas2dox Pas2dox is a pre-processor addon for the Doxygen documentation generator.
"Daraja" means "bridge" in Swahili. The Daraja Framework serves as a bridge between incoming HTTP requests and the Object Pascal code that handles them, enabling seamless integration between web traffic and application logic. — ChatGPT, OpenAI (May 2025)