In 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
Batak beraksi @doni_erlang
» EvelynAtcheson (EvelynAtcheson): Ocaml hosting-selective the ruling circles erlang intertwine hosting perquisite http://t.co/AZ6rLTgEBm
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
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
VOIP: #Engineering #Network #VOIP #Erlang #Ethernet #Codec #Voice #Bandwidth #Signaling #Protocol #Firewall #Security #Encryption
» CWMma (Calvin Metcalf): I always thought the band @OurNameIsFun’s name was an #erlang reference.
I always thought the band @OurNameIsFun’s name was an #erlang reference.
Number of aggregated posts: 10651
Most recent article: May 21, 2013
» 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…