/nginx-haxe

Haxe externs for the Nginx lua module api

Primary LanguageHaxe

Nginx-haxe - Haxe externs for the Nginx Lua api

Build Status

This is a set of externs for Nginx's Lua scripting api.

To use it, you must have an Nginx installation compiled with Lua support. You also must have an up to date version of Haxe 3.3 for the new Lua target (currently unreleased, but available as a nightly or from source).

You can use the lua generated code in a few different ways. Here's an nginx.conf that executes a haxe-compiled lua script for a given location:

[...]
    server {
        listen       8080;
        server_name  localhost;

        location /hellolua {
            default_type 'text/plain';
            content_by_lua_file /path/to/ngx.lua;
        }

        [...]
   }

You can create a simple hello world example:

import Ngx;
class Main {
   public static function main() {
      Ngx.say("hello from haxe!");
   }
}

Make sure to include the source for this library in your class path:

-main Main
-lua ngx.lua
-cp /path/to/nginx-haxe

Note that Nginx will cache the lua code the first time it is loaded. If you're doing development work, you may want to avoid this by setting the appropriate config.