Fork me on GitHub

A HTTP Server to work with
web applications written in Lua

  1. Installation

    $ luarocks install pegasus
  2. Usage

    local pegasus = require 'pegasus'

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

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

    Requests

    Properties

    • path Request path
    • headers Headers data table
    • methods GET, POST, etc...
    • querystring Dictionary with all the GET parameters

    Responses

    Methods

    • post()
    • addHeader(string:key, string:value)
    • addHeaders(table:headers)
    • statusCode(number:statusCode, string:statusMessage)
    • contentType(string:value)
    • write(string:body)
    • writeFile(string:file)
    local pegasus = require 'pegasus'

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

    server:start(function (req, rep)
      rep:addHeader(Cache-Control, no-cache)
         :write('hello pegasus world!')
    end)