ProductPromotion
Logo

Lua

made by https://0x3d.site

GitHub - EvandroLG/pegasus.lua: :rocket: Pegasus.lua is an http server to work with web applications written in Lua language.
:rocket: Pegasus.lua is an http server to work with web applications written in Lua language. - EvandroLG/pegasus.lua
Visit Site

GitHub - EvandroLG/pegasus.lua: :rocket: Pegasus.lua is an http server to work with web applications written in Lua language.

GitHub - EvandroLG/pegasus.lua: :rocket: Pegasus.lua is an http server to work with web applications written in Lua language.

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

  • Compatible with Linux, Mac and Windows systems
  • Easy API
  • Support Lua >= 5.1
  • Native support for HTTP Streaming, aka chunked responses. Check how it works.
  • Native plugin to compress responses using the "gzip" method

API

Parameters

  • host:string Host address where the application will run. By default it uses localhost
  • port:string The port where the application will run. By default it's 9090
  • location:string Path used by Pegasus to search for the files. By default it's the root
  • plugins:table List with plugins
  • timeout:number It's a timeout for estabilishing a connection with the server

Request

Properties

  • path:string A string with the request path
  • headers:table A table with all the headers data
  • method:function The output is the request method as a string ('GET', 'POST', etc)
  • querystring:string It returns a dictionary with all the GET parameters
  • ip:string It returns the client's ip
  • port:number It returns the port where Pegasus is running

Response

Methods

  • addHeader(string:key, string:value) Adds a new header
  • addHeaders(table:headers) It adds news headers
  • statusCode(number:statusCode, string:statusMessage) It adds a Status Code
  • contentType(string:value) Adds a value to Content-Type field
  • write(string:body) It creates the body with the value passed as parameter
  • writeDefaultErrorMessage(statusCode: string, message:body) It sets an HTTP status code and writes an error message to the response
  • writeFile(string:file) It creates the body with the content of the file passed as parameter
  • post():table It returns a dictionary with all the POST parameters
  • redirect(location:string, temporary:boolean): Makes an HTTP redirect to a new location. The status code is set to 302 if temporary is true and false otherwise.
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

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

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

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

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

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

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

server:start()
  • pegasus.plugins.tls
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

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory