iLua Server Module

This module implements a simple HTTP server based on Mongoose library.

Server library

Create a new server object, optionally starting to listen to port. Otherwise, the port can be specified with server:option.
Destroys the server.
server:option(name[, value])
Set or retrieve an option. Returns the old option value, and replaces it with the new value if value is specified. List of available options can be found here.
server:route(path, func)
Requests with URI matching path regex will be handled by function func (expressions are checked in the order they were added). The function arguments are the connection object and the regex match (or a list of strings if the regex was created with re.LIST flag).
server.redirect(url[, code])
Create a function that will generate a redirect header to url, with status code (default is 302: Found, which is a temporary redirect).

Server connection object

server.connection extends the stream type, implementing the write operations. Note that status and headers must be sent before any write operations (status is sent before headers).

Send status code.
server.connection:sendheader(name, value)
Send HTTP header. Length header does not need to be sent as the connection will transfer the content in chunks. by Riv ([email protected]) - All rights reserved