Skip to content
The freshest Erlang web framework
Latest commit fe694ef Feb 17, 2011 Devin Torres Move to public domain
Failed to load latest commit information.
ebin Move to public domain Feb 17, 2011
src Move to public domain Feb 17, 2011
.gitignore Initial commit Nov 5, 2010
Makefile Initial commit Nov 5, 2010 Update documentation Nov 5, 2010
UNLICENSE Move to public domain Feb 17, 2011

Fresh - The freshest Erlang web framework

What's so fresh about it?

Fresh is a Sinatra inspired Erlang web framework based on Mochiweb that supports registering multiple "web handlers" that are dispatched to when you access a Fresh instance. This allows you to theoretically serve sections of your website from multiple physically separate computers. For instance, your main pages could serve from a server in Hong Kong while your user pages are served from Marfa, TX.

What's it look like?



-export([dispatch_rules/0, 'GET'/2]).

dispatch_rules() ->
    fun('GET', ["fresh"], _Req) -> true;
       ('POST', ["fresh"], _Req) -> true;
       (_, _, _) -> false end.

'GET'(["fresh"], _Req) ->
    "So fresh!".

'POST'(["fresh"], Req) ->
    Body = Req:recv_body(),
    {json, [{ok, Body}]}.



-export([start/0, stop/0]).
-export([init/1, start/2, stop/1]).

start() -> application:start(?MODULE).
stop()  -> application:stop(?MODULE).

start(_Type, _Args) ->
    supervisor:start_link({local, example_sup}, ?MODULE, []).

stop(_State) -> ok.

init([]) ->
    WebHandler = {example_web_handler,
                  {fresh_handler, start_link, [example_web_handler]},
                   permanent, 5000, worker, [fresh_handler]},
    {ok, {{one_for_one, 10, 10}, [WebHandler]}}.

{application, example, [
    {description, "A Fresh example app"},
    {vsn, "0.1"},
    {applications, [kernel, stdlib, sasl]},
    {modules, [example, example_web_handler]},
    {registered, [example]},
    {mod, {example, []}}


  • port: port number, default: 7235


  • Allow custom error handlers (easy)
  • Register new dispatch rules during hot OTP upgrade (harder)
  • Statically analyze handler AST during registration to create preliminary dispatch rules (hardest)
Something went wrong with that request. Please try again.