Help with middleware

10 views
Skip to first unread message

Dmitrii Dimandt

unread,
Jul 16, 2009, 8:02:31 AM7/16/09
to ewgi
I can't understand how it works or how to make it work :)

I'm looking at smak, http://github.com/skarab/smak and I don't get
it :)


ok, I can run

application:start(ewgi).
application:start(smak).

But what next? :)



BTW. smak doesn't compile for me unless the following errors are
corrected:
1. Recompile: src/smak_url
include/smak.hrl:17: type ewgi_response() already defined

Comment out type ewgi_response(... in smak.hrl

2. src/smak_route.erl:62: type gb_tree() undefined (and many more
like this one)

change gb_tree() to gb_rees:gb_tree() everywhere there's a typespec

Hunter Morris

unread,
Jul 16, 2009, 8:09:00 AM7/16/09
to ew...@googlegroups.com
2009/7/16 Dmitrii Dimandt <dmit...@gmail.com>:

> I can't understand how it works or how to make it work :)
>
> I'm looking at smak, http://github.com/skarab/smak and I don't get
> it :)

I'm afraid Smak itself as an application isn't really fit for public
consumption (yet). I'll be merging my proprietary codebase at
Smarkets (which fixes the errors you mentioned along with many others)
with the public Smak codebase as soon as possible.

As for ewgi, I've just added some introductory documentation to the
project (which you can find in README.rst or on the main github
project page: http://github.com/skarab/ewgi/tree/master). You are
best off starting with the MochiWeb "Hello, wordl" example and
building your application from there.

Best,
Hunter

Dmitrii Dimandt

unread,
Jul 16, 2009, 8:22:04 AM7/16/09
to ew...@googlegroups.com
That's what I did :)

The "ewgi_context in, ewgi_context out" is very simple, so I ported
most of beepbeep's functionality (http://github.com/dmitriid/beepbeep)
to it in one evening (though haven't pushed it to github yet).

What I'm most interested in is in creating a middleware stack, and I
can't understand how to actually do that :)

Oh, and there's one more question coming up, but I'll do that in a
different post

Filippo Pacini

unread,
Jul 16, 2009, 9:10:18 AM7/16/09
to ew...@googlegroups.com
Hi Dmitrii,
each middleware component is simply a callable that accept a
ewgi_context does something and returns a modified ewgi_context

Then you chain the calls. The chaining can be done where you want.
I usually do it in the dispatcher.

Here is a slightly modified version of the hello world example with a
middleware module. Hope this helps:
http://gist.github.com/148396

Dmitrii Dimandt

unread,
Jul 16, 2009, 9:22:46 AM7/16/09
to ew...@googlegroups.com
Oh, so it's just a simple F(G(H(....X(C))) where F, G, H, ..., X are
just middleware modules?

Hm... I see now... Time to experiment! :)
Reply all
Reply to author
Forward
0 new messages