lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


In the tradition of [1], here is a Lua incarnation of its URL handling [2].

Notorious "Hello world" example:

local aFunction = function( aName )
        print( "Hello ", aName, "!" )

local someMappings = { "/(.*)", aFunction }

Web:start( someMappings )


> Hello Earthling!

Web:start() takes an orderer table of pattern/handler pairs.

The pattern captures, if any, are passed to the handler as arguments.

An handler can be either a function, a class name or a class. If the handler is a function, it's invoked without further ado. In the case of a class, the relevant method is looked up and then invoked (e.g. GET -> get() ).


PA, Onnay Equitursay