Daraja Framework RESTful extension 2.4 released

Version 2.4 of the RESTful extension is compatible with the new 1.2 release of Daraja HTTP Framework. It uses the TdjRequest and TdjResponse types instead of TRequest and TResponse. It also uses const string parameters to reduce the overhead caused by refrence counting.

Continue reading

Daraja Framework: commercial license

Daraja Framework is a HTTP service framework for Free Pascal and Delphi 2009 and newer.

Its source code is dual licensed under the GNU Affero General Public License Version 3 and a commercial license, which removes the requirements of the AGPL license. When the annual subscription is terminated, the license is still valid for unlimited time. Termination of the subscription only ends additional services such as the free (basic) support.

Continue reading

Daraja Framework RESTful extension 2.1 released

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

In the past, the separate “experimental” RESTful extension library only compiled with Delphi, as it used anonymous methods.

With version 2.0 / 2.1, the RESTful extension library now also compiles with Free Pascal, where it uses procedural types instead of anonymous methods.

In projects which must be single-source for Delphi and Free Pascal, usage of procedural types can be enforced by defining the symbol DARAJA_RESTFUL_COMPATIBLE.

 

Continue reading

Daraja Framework 1.0 released

Daraja Framework is a new free open source library for Object Pascal (Free Pascal 2.6.4, Free Pascal 3.0, Delphi 2009+) available on GitHub. It is based on the stand-alone HTTP server in Internet Direct (Indy) and the successor to the Habari Web Components library by Habarisoft.

Continue reading

Habari Web Components 2.11 released

Habari Web Components is a web application framework for small to medium size HTTP services, based on the popular open source TCP/IP library for Delphi and Free Pascal, Internet Direct (Indy).

Online demo:  the online demo on https://secure.habariwebcomponents.de/demo/index.html runs on a Ubuntu Linux system (please note that Linux is not officially supported).

Demo download: The demo download contains documentation, tutorial project sources and the “Flightplan” executable demo which uses jQuery mobile.

Mobile app demo

 

Habari Web Components

Habarisoft on-line demo pages migrate to secure domain

Habarisoft started migrating demo web pages for its libraries to the secure domain https://secure.habariwebcomponents.de.

*) the Habari Web Components demo pages include links to non-secure resources (http instead of https) so they may cause browser security warnings.

 

Habari Web Components 2.8 released

The new release 2.8 of the web application framework for Delphi and Free Pascal is available now. Changes include:

  • FPCUnit test project
  • validation of context names and mappings
  • new tutorials with source code
  • updated Flightplan demo for jQuery Mobile
  • Log4D (logging framework) source code workarounds for Free Pascal

Flightplan Demo (using jQuery Mobile 1.4.2)

DUnit and FPCUnit Tests

FPCUnit Tests

About

Habari Web Components is a web application framework for small to medium size HTTP services, based on the popular open source TCP/IP library for Delphi and Free Pascal, Internet Direct (Indy). If you like to see it in action, download and run the off-line demo applications, or go to the on-line demo. Need more information? Browse the on-line API documentation, or read the Getting Started document.

  • supports Delphi 2009 and Free Pascal 2.6.0 or newer with Internet Direct (Indy) 10.6
  • full source code included, with DUnit/FPCUnit tests and example applications
  • redistribution with your application does not require any additional fees
  • free updates for one year

Example source code for Hello World web component

This web component answers HTTP GET requests with a hello world response (content type text/plain). The full tutorial project code is included in the demo download.

unit HelloWorldResource;

interface

uses djWebComponent, IdCustomHTTPServer;

type
  THelloWorldResource = class(TdjWebComponent)
  public
    procedure OnGet(
      Request: TIdHTTPRequestInfo;
      Response: TIdHTTPResponseInfo); override;
  end;

implementation

procedure THelloWorldResource.OnGet(
  Request: TIdHTTPRequestInfo;
  Response: TIdHTTPResponseInfo);
begin
  Response.ContentText := 'Hello world!';
  Response.ContentType := 'text/plain';
end;

end.

 

Habari Web Components

A RESTful CRUD demo application with Delphi

Habari Web Components is a web application framework for small to medium size HTTP services, based on the Internet Direct (Indy) library.

A new demo application – included with full source code in demo/restful-crud – exposes a RESTful API which supports HTTP GET / POST / DELETE commands to read, create and delete data.

The source code below shows the configuration code for the RESTful API. Every request handler is bound to a resource address, document type (MIME type), and HTTP method.

Note that PUT is not yet implemented in the API because web browsers do not support HTTP PUT in HTML forms. For HTTP DELETE, the web interface uses a Javascript-based workaround to delete a resource.


procedure TMyRestfulComponent.Init(const Config:
            IWebComponentConfig);
begin
  inherited; // always call inherited.Init

  // GET http://localhost/rest/persons
  // list all persons
  &Path('persons');
  Produces('text/html');
  GET(procedure(Request: TRequest; Response: TResponse)
  begin
    Response.ContentText := CRUDModule.GetPersons;
    Response.CharSet := 'UTF-8';
  end);

  // POST http://localhost/rest/persons
  // add new person
  &Path('persons');
  Produces('text/html');
  POST(procedure(Request: TRequest; Response: TResponse)
  var
    Name: string;
    Person: TPerson;
  begin
    Name := UTF8Decode(Request.Params.Values['name']);
    Person := TPerson.Create(CRUDModule.NextID, Name);
    CRUDModule.SavePerson(Person);
    Response.Redirect(Request.Document);
  end);

  // PUT http://localhost/rest/persons/{id}
  // update person
  &Path('persons/{id}');
  Produces('text/html');
  PUT(procedure(Request: TRequest; Response: TResponse)
  var
    ID: string;
  begin
    ID := Request.Params.Values['id'];
    // TODO
  end);

  // DELETE http://localhost/rest/persons/{id}
  // delete person
  &Path('persons/{id}');
  Produces('text/html');
  DELETE(procedure(Request: TRequest; Response: TResponse)
  var
    ID: string;
  begin
    ID := Request.Params.Values['id'];
    CRUDModule.DeletePerson(StrToInt(ID));
  end);

  // GET http://localhost/rest/persons/{id}
  // get person information
  &Path('persons/{id}');
  Produces('text/html');
  GET(procedure(Request: TRequest; Response: TResponse)
  var
    ID: string;
  begin
    ID := Request.Params.Values['id'];
    Response.ContentText := CRUDModule.GetPerson(StrToInt(ID));
    Response.CharSet := 'UTF-8';
  end);
end;

Habari Web Components