Erlang Web

Usage

The Erlang Web is being used commercially world wide. Example websites are:


Key features

The Erlang Web introduces a different approach to generating dynamic pages. It allows merging XHTML code with a dedicated XML tag called wpart. With the concept of wparts, it is possible to develop pieces of functionality that can be reused in different pages, providing solid framework for developing dynamic web services. A set of frequently used patterns has been implemented as a common library of wparts. Some examples of wparts include:

Moreover, the wtypes mechanism allows formatting date, time and numbers; and validation of data that comes with GET/POST requests. Formatting and validation can also be done for user defined complex types. Such complex types can consist of basic or other complex types and can be defined using Erlang record syntax. This is convenient when data is kept in the Mnesia database, however the data can be kept in other databases like MySQL or PostgreSQL as well.

To make URLs easier to remember, Erlang Web provides a dispatcher engine based on regular expressions which maps URLs to controller calls. Each call to the controller function can be preceeded with and followed by calls to the so-called dataflow functions. With the template inheritance and support for multilingual sites, the Erlang Web is a complete tool for building web applications.

Wparts

Having wparts defined as XML elements allows the Erlang Web to validate a page with an XML parser ensuring that what is sent to the client browser is free of XHTML errors. A parsed file is converted to Erlang binary and cached on disk or kept in the memory.

Wtypes

Wtype module is responsible for validating and formatting the data of some type. The Erlang Web provides over 10 simple basic types like dates, integers, strings, etc. and it is easy to add new ones. A Developer can build his own complex types on top of them. Without additional development effort validation and generation of forms for create/ update operations can be automated.

Example Code - for a simple scenario

The diagram below shows an example of wpart people, that is used to add dynamic content to the page.

When "/app/mod/func/people.html" URL is visited, the controller function mod:func() is called. The function reads data from the model and prepares it for the wpart people. During page rendering, wpart tag is expanded with the dynamic data.

Click here to see sample code of above diagram

Example Code Two - listing the person with a given id and adding a new person

The example illustrates dispatching a request with the dispatcher, logging the request with a dataflow function, validating, automatic form building and error handling.

Click here to see the sample code two



erlang