[erlang-questions] Similarities between web programming and functional programming

Tony Arcieri <>
Mon Jun 14 18:47:34 CEST 2010

On Sat, Jun 12, 2010 at 2:37 PM, Jesper Louis Andersen <
> wrote:

> Look at the following function:
> handle(Request) ->
>  X = ...,
>  Template = ...,
>  render_response(?HTTP_OK, X, Template).
> It has the specification contract
> -spec handle(request()) -> response().
> That is, handling incoming web requests are (sometimes pure) functions
> from request() objects to response() objects. At this point, we are
> essentially done. There isn't much more to it.

The problem with this approach is you must construct the entire response
before you can even begin sending it back to the client.  This is especially
problematic with things like the document <head> section which contain
directives to fetch additional assets from the server (e.g. stylesheets,

A better approach is to stream the response back to the client as it's

Tony Arcieri
Medioh! A Kudelski Brand

More information about the erlang-questions mailing list