Home

Awesome

pegasus.lua

An http server to work with web applications written in Lua language check the site.

Unix build Lint HuBoard
badge Gitter

Installation

To install Pegasus.lua, run:

$ luarocks install pegasus

How does it work?

Follow an example:

local pegasus = require 'pegasus'

local server = pegasus:new({
  port='9090',
  location='example/root'
})

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

Or try the included examples.

Features

API

Parameters

Request

Properties

Response

Methods

local pegasus = require 'pegasus'

local server = pegasus:new({ port='9090' })

server:start(function (req, rep)
  rep:addHeader('Date', 'Mon, 15 Jun 2015 14:24:53 GMT'):write('hello pegasus world!')
  return rep:close()
end)

Native Plugin

local Pegasus = require 'pegasus'
local Compress = require 'pegasus.plugins.compress'

local server = Pegasus:new({
  plugins = { Compress:new() }
})

server:start()
local Pegasus = require 'pegasus'
local Downloads = require 'pegasus.plugins.downloads'

local server = Pegasus:new({
  plugins = {
    Downloads:new {
      prefix = "downloads",
      stripPrefix = true,
    },
  }
})

server:start()
local Pegasus = require 'pegasus'
local Files = require 'pegasus.plugins.files'

local server = Pegasus:new({
  plugins = {
    Files:new {
      location = "./",
      default = "index.html",
    },
  }
})

server:start()
local Pegasus = require 'pegasus'
local Tls = require 'pegasus.plugins.tls'

local server = Pegasus:new({
  plugins = {
    TLS:new {
      wrap = {
        mode = "server",
        protocol = "any",
        key = "./serverAkey.pem",
        certificate = "./serverA.pem",
        cafile = "./rootA.pem",
        verify = {"none"},
        options = {"all", "no_sslv2", "no_sslv3", "no_tlsv1"},
      },
      sni = nil,
    },,
  }
})

server:start()

Contributing

Install Dependencies

$ make install_dependencies

Running tests

$ make unit_test