The State of Erlang Web Middleware – EWGI and SimpleBridge
Erlang Inside - Chad DePue - December 28, 2009In the interest of publishing more often and covering smaller topics, lets review web-server-agnostic middleware for Erlang.
The current standard for Erlang web application middleware is EWGI, inspired by Python’s PEP 333 and providing similar functionality as Ruby’s Rack. All major Erlang web servers support EWGI, and most web frameworks.
Created by Rusty Klophaus, SimpleBridge “takes the pain out of coding to multiple Erlang web servers by creating a standardized interface.” It is used by the soon to be released new version of The Nitrogen Web Framework. According to Rusty, SimpleBridge has some improvements over EWGI, such as a smaller code base; more easily extendable (Takes about 150 lines to add support for a new HTTP server, vs. ~350 for EWGI; support for multipart file uploads, with size limits and handle-able errors; static file support; more specific interface functions for getting and setting cookies.
However, based on my experience with Rack, Multipart file uploads, static file support, and anything but basic cookie manipulation are all best handled by a web server such as nginx or a reverse proxy like HAProxy anyway. Perhaps it is better that EWGI tries to do less in this case…
Let’s look at a simple EWGI example with MochiWeb (shamelessly pulled from the docs)…
First we startup mochiweb calling the loop/1 function. Mochiweb will call our loop/1 function whenever a request is received.

In loop/1 we setup a call to our simple implementation of the EWGI interface.

Now the EWGI implementation is called with a tuple that aways starts with ewgi_context, and contains a Request and a Response. This code returns a 5-tuple response (further details in the documentation).

EWGI solves the problem of creating a standard interface to middleware components. It has become the standard, and the power of such standards lies in their implementations’ ubiquity. Making your own hit web framework at home in your spare time has never been easier.
Categories: Blogs Erlang Inside
Erlang on Twitter
» pakmbos (Beny herlambang): Batak beraksi @doni_erlang
» EvelynAtcheson (EvelynAtcheson): Ocaml hosting-selective the ruling circles erlang intertwine hosting perquisite http://t.co/AZ6rLTgEBm
» jfloodnet (Joseph Flood): I’m learning me some Erlang for great good. You should too! http://t.co/UYLoBAUHG6
» TrainByTweet_VO (TrainByTweet_VO): VOIP: #Engineering #Network #VOIP #Erlang #Ethernet #Codec #Voice #Bandwidth #Signaling #Protocol #Firewall #Security #Encryption
» toratorax (Mitsugu(じぇじぇじぇ)): RT @shigeyas: 新しい計算機の言語やプラットフォーム覚えるのは、いまや全く困難がないので(HaskellとかErlangとかちょっと困るぐらい)、「ナルホド」って思うことがあんまりなかったのだが、
今やってる仕事の関係での数学的な復習は、わりとナルホドが多く、
大学…
» haryohp (haryo prasetyo): Waaaw RT @erlangprwggn: Yg nduty nduty toya RT @haryohp: Erlang nyoblos yg mana ? RT @erlangprwggn: Nyoblosnya siangan aja deh, biar nanti
» CWMma (Calvin Metcalf): I always thought the band @OurNameIsFun’s name was an #erlang reference.
» shigeyas (Shigeya): 新しい計算機の言語やプラットフォーム覚えるのは、いまや全く困難がないので(HaskellとかErlangとかちょっと困るぐらい)、「ナルホド」って思うことがあんまりなかったのだが、
今やってる仕事の関係での数学的な復習は、わりとナルホドが多く、
大学での勉強不足を実感
» Chazu (Chazu): Two problems down in project euler erlang edition 2013. Now only 427 to go. I’m totally screwed.
» erlangprwggn (Purwànggono): Yg nduty nduty toya RT @haryohp: Erlang nyoblos yg mana ? RT @erlangprwggn: Nyoblosnya siangan aja deh, biar nanti kalo jagoanku menang
Statistics
Number of aggregated posts: 10651
Most recent article: May 21, 2013
Latest comments
» Moraru on This is Why You Spent All that Time Learning to Program: It is true that computer science was a pain in the back at time that i’ve had to learn it…
» Commercial hand dryers on Couchbase Meetup at new HQ: Buy online from here where you will get so much of variety in Commercial hand dryers for people. If you…
» Fort McMurray Homes on Motivated Reasoning and Erlang vs Python vs Node: I don’t really understand why this post is motivational? I don’t even see a post, just a title. Fort McMurray…