fmqa / lua-fcgi

A Lua module for writing FastCGI applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A minimal FastCGI library for Lua.

Requirements

lua >= 5.1, libfcgi

Usage

example.lua

local fcgi = require( "fcgi" )

while fcgi.accept() do
	fcgi.print( "Content-Type: text/plain; charset=utf-8\r\n\r\n" )
	fcgi.print( "uri\t" .. fcgi.getenv( "DOCUMENT_URI" ) .. "\n" )
	fcgi.print( "agent\t" .. fcgi.getenv( "HTTP_USER_AGENT" ) .. "\n" )
	fcgi.print( "query\t" .. fcgi.getenv( "QUERY_STRING" ) .. "\n" )
	fcgi.print( "post\t" .. fcgi.post() .. "\n" )
	fcgi.print( "env\n" )
	fcgi.dumpenv()
end

nginx.conf

location / {
	include fastcgi_params;
	fastcgi_pass 127.0.0.1:9000;
}

Then

$ spawn-fcgi example.lua -p 9000
$ curl localhost/path?get -d post
uri	/path
agent	curl/7.34.0
query	get
post	post
env
FCGI_ROLE=RESPONDER
QUERY_STRING=get
...

About

A Lua module for writing FastCGI applications


Languages

Language:C 92.8%Language:Makefile 7.2%