comotion / pegasus.lua

Pegasus.lua is a http server to work with web applications written in Lua language.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pegasus.lua

Pegasus.lua is a http server to work with web applications written in Lua language.

pegasus.lua

Installation

To install Pegasus.lua, run:

$ luarocks install pegasus

How does it work?

Follow an example:

local pegasus = require 'pegasus'

local server = pegasus:new('9090')

server:start(function (reqest, response)
  print "It's running..."
end)

API

Request

Properties

  • path A string with the request path
  • headers A table with all the headers data
  • method The output is the request method as a string ('GET', 'POST', etc)
  • querystring It returns a dictionary with all the GET parameters
  • post It returns a dictionary with all the POST parameters

Response

Methods

  • writeHead(number) It creates the head; the function receives a status code by parameter
  • finish(string) It creates the body; it accepts a content as parameter
local pegasus = require 'pegasus'

local server = pegasus:new('9090')

server:start(function (req, rep)
  rep.writeHead(200).finish('hello pegasus world!')
end)

Contributing

Install Dependencies

$ make install_dependencies

Running tests

$ make test

About

Pegasus.lua is a http server to work with web applications written in Lua language.


Languages

Language:Lua 95.4%Language:HTML 3.4%Language:Makefile 1.3%