ํ๋ก์ ํธ
GitHub์์ ๋ณด๊ธฐ
EvandroLG/pegasus.lua
์๊ฐ
๐ Pegasus.lua๋ Lua๋ก ์์ฑ๋ ์น ์ ํ๋ฆฌ์ผ์ด์ ์ ์คํํ๊ธฐ ์ํ HTTP ์๋ฒ์ ๋๋ค.
์์คํ ๋ฐ ์ธํ๋ผWhat you can do
- Compatible with Linux, Mac and Windows systems
- 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
์ธก์ ๋ ์คํ ์ฆ๊ฐ
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- ๊ธฐ๋ก ์์ง ์ค
์๋ก ๊ฒน์น๋ ๊ธฐ๊ฐ์ ์์ฆ๊ฐ๋์ด๋ฉฐ ์ผ๋ณ ํฉ๊ณ๊ฐ ์๋๋๋ค. ์ธก์ ๊ฐ์ด ์์ผ๋ฉด ๋น์ ๋ก๋๋ค. ์คํ๋ ๊ด์ฌ๋๋ฅผ ๋ํ๋ด๋ฉฐ ํ์ง์ ๋ณด์ฅํ์ง ์์ต๋๋ค.
README.md
OriginalAn http server to work with web applications written in Lua language check the site.
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:stringHost address where the application will run. By default it useslocalhostport:stringThe port where the application will run. By default it's9090location:stringPath used by Pegasus to search for the files. By default it's the rootplugins:tableList with pluginstimeout:numberIt's a timeout for estabilishing a connection with the server
Request
Properties
path:stringA string with the request pathheaders:tableA table with all the headers datamethod:functionThe output is the request method as a string ('GET', 'POST', etc)querystring:stringIt returns a dictionary with all the GET parametersip:stringIt returns the client's ipport:numberIt returns the port where Pegasus is running
Response
Methods
addHeader(string:key, string:value)Adds a new headeraddHeaders(table:headers)It adds news headersstatusCode(number:statusCode, string:statusMessage)It adds a Status CodecontentType(string:value)Adds a value to Content-Type fieldwrite(string:body)It creates the body with the value passed as parameterwriteDefaultErrorMessage(statusCode: string, message:body)It sets an HTTP status code and writes an error message to the responsewriteFile(string:file)It creates the body with the content of the file passed as parameterpost():tableIt returns a dictionary with all the POST parametersredirect(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
๊ด๋ จ ํ๋ก์ ํธ ์ดํด๋ณด๊ธฐ
๋ถ๋ฌ์ค๋ ์คโฆ