A lightweight HTTP server framework for Object Pascal (Delphi 2009+ / Free Pascal 3.0)
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.github/ISSUE_TEMPLATE Update issue templates May 3, 2018
demo format html Apr 21, 2018
doc Documentation fixes Feb 24, 2018
make 1.2-a1 getting started, fixes 47 Jan 27, 2017
source version 1.2.4 Apr 21, 2018
test/unittests resolves #73 Feb 23, 2018
.gitignore resolves #76 Feb 23, 2018
INDY-LICENSE.md Initial commit Mar 19, 2016
LICENSE Initial commit Mar 19, 2016
README.md fix PDF link Feb 1, 2017


Daraja Framework

Daraja is a flexible HTTP server framework for Object Pascal, based on the stand-alone HTTP server in the free open source library Internet Direct (Indy).

Daraja provides the core foundation for serving HTTP resources of all content-types such as HTML pages, images, scripts, web service responses etc. by mapping resource paths to your own code. Your code then can create the response content, or let the framework serve a static file.

Optional Extensions


A RESTful framework extension, version 1.0 is compatible with Delphi 2009 and newer. Version 2.0 introduces support for Free Pascal, using a slightly different configuration of RESTful resource handlers.



A simple logging facade with support for LazLogger, Log4D, and other logging frameworks.


You can find this project at https://github.com/michaelJustin/daraja-framework


Getting Started PDF

A Getting Started document (PDF) is available at https://www.habarisoft.com/daraja_framework/1.2/docs/DarajaFrameworkGettingStarted.pdf

Project home page

Visit https://www.habarisoft.com/daraja_framework.html for more information.

IDE configuration

Required paths

  • The project search path must include the Indy and Daraja source directories.



  • The project search path for Include files must include the Indy Core path.



Optional source

Some useful (but optional) units are located in the optional subfolder. Include it when needed:


Usage example: contexts

In the Daraja Framework, contexts are used for the high-level separation of HTTP resources, depending on their first path segment. Here is an example which uses two contexts, 'context1' and 'context2':


This example uses 'news', 'files' and 'admin' contexts:



In the Daraja Framework, creating a context only requires the context name as the parameter of the TdjWebAppContext constructor:

  Server := TdjServer.Create;
    Context1 := TdjWebAppContext.Create('context1');
    Context2 := TdjWebAppContext.Create('context2');

Dynamic resource handlers

Contexts need resource handlers to process requests. A resource handler is responsible for the generation of the HTTP response matching a specific client request.

However, the routing between the actual HTTP request and the resource handler is performed via 'mapping' rules.

For example, a resource handler which returns a HTML document could be mapped to the /context1/index.html resource path with this absolute path resource handler mapping:

Context1.Add(TIndexPageResource, '/index.html');

Alternatively, a more general suffix mapping resource handler may be used, which should handle requests to any resources with the extension *.html:

Context1.Add(TCatchAllHtmlResource, '*.html');

This resource handler will be invoked for all requests for *.html resources - independent of their actual document name, and also for resources in sub-paths like /context1/this/works/with_any_page.html. (But note: the resource handler will not receive requests for other context, such as /context2/index.html!)