Daraja HTTP Framework 3.2.1-SNAPSHOT
HTTP server framework for Object Pascal
Loading...
Searching...
No Matches
Welcome to Daraja HTTP Framework!

Introduction

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. It enables developers to create well-structured HTTP server applications, written with 100% open source code, targeting both Delphi 2009+ and Lazarus 4.x / FPC 3.2.x from the same codebase.

It allows to compose web applications with these building blocks:

Copyright (c) 2016 Michael Justin https://www.habarisoft.com/ Mail: info@.nosp@m.haba.nosp@m.risof.nosp@m.t.co.nosp@m.m

Features

  • URL-pattern routing — map requests to handler classes by exact, prefix, suffix or default patterns
  • Web components — handle requests by overriding per-method hooks (OnGet, OnPost, OnPut, ...)
  • Filter chains — pluggable pre- and post-processing of requests and responses
  • Contexts — group resources under a base path with their own init parameters, see TdjWebAppContext
  • HTTP sessions — server-side session state with configurable timeout
  • Static content — serve files from a directory with path-traversal protection (TdjDefaultWebComponent, in the unsupported source/optional folder)
  • Optional helpers — NCSA access logging and request-statistics filters
  • Dual compiler support — one codebase for Delphi 2009+ and Lazarus 4.x / FPC 3.2.x
  • AGPL or commercial — 100% open source, with a commercial license available

Example

A minimal "Hello, World!" web component, handling HTTP GET requests:

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;
HTTP request information.
HTTP response information.
A base class which can be subclassed to create a HTTP component for a Web site.
Definition djWebComponent.pas:63

The component is then registered under a context and served by a TdjServer instance. See the demo/01_helloworld demo application for the full, runnable example, and the demo folder for more examples covering sessions, filters, static content, server-sent events and OpenID Connect.

Documentation

  • This site is the API reference, generated from the doc comments in the source folder.
  • A getting started guide is available at DarajaFrameworkGettingStarted.pdf.
  • The project README, on GitHub, covers installation, dependencies and the release changelog.

Licensing

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. You can be released from the requirements of the AGPL license by purchasing a commercial license, obtainable from habarisoft.com.

Trademarks

Habari is a registered trademark of Michael Justin and is protected by the laws of Germany and other countries. Embarcadero, the Embarcadero Technologies logos and all other Embarcadero Technologies product or service names are trademarks, servicemarks, and/or registered trademarks of Embarcadero Technologies, Inc. and are protected by the laws of the United States and other countries. Other brands and their products are trademarks of their respective holders.