Catch ALL requests by LUA-script

HowToMeetLadies nginx-forum at nginx.us
Mon May 2 08:11:10 MSD 2011


Maybe slightly off-topic but then maybe it is useful for you (andiL) or
someone else.

Before i start, @agentzh: every ?nth request, one of nginx
(0.8.54.4rc2-jit2beta6) worker processes segfaults, is this behaviour
related to the pcre issue? have not patched it yet.. ah and thank you
*very* much for giving nginx this all new powers!! ((:

Ok, im a long time nginx/redis/ruby user and this are my first steps
with lua and a lightweight (M)VC framework around three core "classes",
which uses haml for templates/layout and markdown for text processing (5
minute ffi discount binding), drizzle and redis for data and redis also
for caching. Successfully running a little app with it. yay! *.* For now
i can give you some snippets just to show some basic aspects, ill
release a fully working example sometime soon, if the segfaults doesnt
belong to the pcre-issue ill try to debug that too.


Below ill use luasql, instead you can use
ngx.location.capture("/some-internal-rds-json") and lua-yajl, but this
approach ends as soon as you want INSERT followed by LAST_INSERT_ID() or
other complex queries/transactions (as long as libdrizzle has no support
for multiple queries, maybe this is not the best option to go with, ive
tried alternatives and workarounds, but for now this is what *I* want).

At the moment i do not need an ORM for my data, but have already done
some functions for both rds_json and luasql. redis has some commands
exposed in nginx.conf for easy access with lua (: The core classes:

Request; which contains several ngx.var wrappers (for nil instead of ''
for empty keys), present(str), simple cookie/session/login, before/after
filters, haml/markdown rendering, etc..

MethodRequest < Request; which calls functions for HTTP Methods aka GET,
POST alike..
and finally Resource < MethodRequest; which has an
Rails-ActionController-like interface.


Greetz
# HTML

--- ATTACHMENT ---

ookeh to bad no code formatting...?

http://exc.eu/paste/deadbeaf.txt

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,179364,194903#msg-194903




More information about the nginx mailing list