[erlang-questions] Erlang Web Libraries & Frameworks

Joe Armstrong erlang@REDACTED
Thu Aug 11 11:01:07 CEST 2011

On Wed, Aug 10, 2011 at 1:04 AM, Sam Elliott <sam@REDACTED> wrote:
> Hi erlang-questions,
> Recently I needed to compare a few Erlang web libraries and frameworks
> for a friend who was writing a simple internal API endpoint. He
> suggested I should publish the rundown for others, and I thought I'd
> also circulate it here. I'm relatively new to Erlang, so I have
> probably missed a few libraries.
> I'll try to keep it updated as people send me information, so don't
> hesitate to contact me if i've got something wrong.
> The article: http://lenary.co.uk/erlang/2011/08/erlang-web-libraries/
> What are your thoughts?

This is great. In addition to your summaries (which are excellent) I'd
like to see
a simple cross-framework API. Is what your friend is doing?

For example, If I start off by using yaws and then change my mind
later and decide to use mochiweb
I'd like this to have minimal impact on my code. It should be a simple
as changing the name of
an interface module. (( ie a GoF adapter pattern ))

To use yaws I'd like to write:

    -define(?ADAPTOR, yaws_adapter).


    -import(?ADAPTOR, [my_callback/1, reply/1, start_web_server/0]).

    start() ->
           ?ADAPTER:my_callback(fun my_handler/1).

    my_handler(X) when is_record(X,'GET') ->
           ?ADAPTER:reply(#'RELY'{type=html, data=Binary})

If I wanted to use mochiweb I'd just have to change the module name of
the adaptor.
(this was the original reason for the import declaration in Erlang -
to make changing the
implementation of a feature simple :-)

Exactly which routines the adapter would export and the records in
the include file would need a little thought - but handling
HTTP GET, POST, PUT, DELETE requests should be easy enough

If all suppliers of web- frameworks could adopt a common adapter
pattern - it would make
life a lot easier. I realize that this would not allow us to use some
of the finer facilities
offered by an individual web-server, but it would be very useful for the simple
cases of serving up files etc.

One could have a common API then choose the implementation depending upon
the requirements of the application.


> Sam
> --
> Sam Elliott
> --
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list