WSAPI
Lua Web Server API

Overview

WSAPI is an API that abstracts the web server from Lua web applications. By coding against WSAPI your application can run on any of the supported servers and interfaces (currently CGI, FastCGI and Xavante, on Windows and UNIX-based systems).

WSAPI provides a set of helper libraries that help with request processing and output buffering. You can also write applications that act as filters that provide some kind of service to other applications, such as authentication, file uploads, request isolation, or multiplexing.

WSAPI's main influence is Ruby's Rack framework, but it was also influenced by Python's WSGI (PEP 333). It's not a direct clone of either of them, though, and tries to follow standard Lua idioms.

WSAPI is free software and uses the same license as Lua 5.1

Status

Current version is 1.2. It was developed for Lua 5.1.

Download

You can get WSAPI using LuaRocks:

luarocks install wsapi-xavante

Unix Installer Script

You can also get an installer script that installs Lua+LuaRocks+WSAPI here. See the manual for installation instructions.

Customizing the installer

There is a section of wsapi-install-1.2 with the parameters that control the installer:

# Installer parameters 

LUA_VERSION=5.1.4 
PACKAGE=WSAPI 
PACKAGE_OPT=wsapi 
PACKAGE_ROCK=wsapi-xavante 
INSTALLER_VERSION=0.6 
PACKAGE_VERSION=1.2 
LUAROCKS_REPO=http://luarocks.org/repositories/rocks
LUAROCKS_URL=http://www.luarocks.org/releases/luarocks-2.0.1.tar.gz
LUAROCKS_VERSION=2.0.1 

To install something else change PACKAGE to the full name of the package, PACKAGE_OPT to the name of the --with-foo option that lets the user override the version (or skip installation of the package), PACKAGE_ROCK to the name of the rock, and PACKAGE_VERSION to the version. Also change LUAROCKS_REPO if you want to use another repository (the installer uses --from, so will pull packages from other repositories if the one you specified does not have them).

If there is a LuaRocks update then change LUAROCKS_URL and LUAROCKS_VERSION. Changing Lua version is much more involved, so I won't go into that.

Now to make the tarball, put the installer script in an empty folder and run:

bash ./your-install-script --prefix=/tmp/anything --bootstrap 

After it finishes you will have lua-5.1.4.tar.gz, luarocks-2.0.1.tar.gz, and a rocks folder with .src.rocks for all the rocks that the installer installs.

Latest Sources and Bug Tracker

WSAPI sources and bug tracker are available at its Github page.

History

WSAPI 1.2 [27/Oct/2009]

  • Adds time-based collection of Lua states to FCGI and Xavante launchers
  • Adds "wsapi" laucher script, to start a Xavante WSAPI server
  • Fixed "undefined media type" error
  • Added is_empty utility function to check if a string is nil or ''
  • Fixed bug with empty bodies in wsapi.xavante, and added full http status codes to responses
  • Changing order of evaluating PATH_TRANSLATED and SCRIPT_FILENAME, to make non-wrapped launchers work in OSX Apache
  • Reload support for load_isolated_launcher

WSAPI 1.1 [04/Feb/2009]

  • Adds options table to wsapi.request.new, *delay_post* option delays POST processing until req:parsepostdata() is called
  • Moves call to lfs.setmode from wsapi.common to wsapi.cgi
  • Adds wsapi.util.make_rewindable(wsapi_env) method - wraps wsapi_env in a new environment that lets you process the POST data more than once.
  • Correctly handles PATH_TRANSLATED and SCRIPT_FILENAME in case the web server gets creative
  • Statically links the FastCGI version on Windows

WSAPI 1.0 [18/May/2008]

  • First public version.
  • Includes CGI, FastCGI and Xavante WSAPI connectors.

Credits

WSAPI was designed and developed by Fabio Mascarenhas and André Carregal, and is maintained by Fabio Mascarenhas.

Contact Us

For more information please contact us. Comments are welcome!

You can also reach us and other developers and users on the Kepler Project mailing list.

Valid XHTML 1.0!