Fork me on GitHub

IServe

About IServe

IServe is a tiny HTTP server in Erlang. It provides you with the ability to listen to receive a callback to a module of your choice for each incoming http request.

-module(iserve_example).
-behaviour(iserve).

-export([start_link/0, iserve_request/2]).

start_link() ->
  application:start(sasl),
  application:start(iserve),
  iserve:add_server({8080, {127, 0, 0, 1}}, ?MODULE, []).

iserve_request(_C, _Req) ->
  erlang:display({_C, _Req}),
  Mime = <<"text/plain;charset=utf-8">>, 
  Body = <<"Hello world!">>,
  iserve:reply_ok([], {Mime, Body}).

IServe has its roots in the excellent article A fast web server demonstrating some undocumented Erlang features written by Sean Hinde.

Torbjörn Törnkvist put the code from the article into a working OTP application.

I have been working on allowing this OTP application to have multiple HTTP listeners running, being able to add them dynamically.

Authors

Source code

Documentation

See the tests-directory for some callback examples.

See also

The ifastcgi erlang FastCGI server

My github page.

License

Keep looking, I believe it is under some BSD-ish license. My commits will all be the same as what Torbjörn and Sean used.