diff --git a/README.md b/README.md index 951f695..881ae1c 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,8 @@ server:start(function (request, response) end) ``` +Or try the [included examples](example/README.md). + ## Features - Compatible with Linux, Mac and Windows systems diff --git a/example/app.lua b/example/app.lua index ba35986..2856077 100644 --- a/example/app.lua +++ b/example/app.lua @@ -10,11 +10,11 @@ package.path = './src/?.lua;./src/?/init.lua;' .. package.path local Pegasus = require 'pegasus' local Compress = require 'pegasus.plugins.compress' local Downloads = require 'pegasus.plugins.downloads' +local Files = require 'pegasus.plugins.files' -- local TLS = require 'pegasus.plugins.tls' local server = Pegasus:new({ port = '9090', - location = '/example/root/', plugins = { -- TLS:new { -- the tls specific configuration -- wrap = { @@ -30,10 +30,15 @@ local server = Pegasus:new({ -- }, Downloads:new { - prefix = "downloads", + location = '/example/root/', + prefix = 'downloads', stripPrefix = true, }, + Files:new { + location = '/example/root/', + }, + Compress:new(), } }) @@ -47,9 +52,10 @@ server:start(function(req, resp) end local data = req:post() - if data then - print(data['name']) - print(data['age']) + print("Name: ", data.name) + print("Age: ", data.age) end + stop = not not resp:writeFile("./example/root" .. path) + return stop end) diff --git a/example/copas.lua b/example/copas.lua index f468fc4..586e128 100644 --- a/example/copas.lua +++ b/example/copas.lua @@ -20,7 +20,7 @@ local Downloads = require 'pegasus.plugins.downloads' -- @tparam[opt] table opts.sslparams the tls based parameters, see the Copas documentation. -- If not provided, then the connection will be accepted as a plain one. -- @tparam[opt] table opts.plugins the plugins to use --- @tparam[opt] function opts.handler the callback function to handle requests +-- @tparam[opt] function opts.callback the callback function to handle requests -- @tparam[opt] string opts.location the file-path from where to server files -- @return the server-socket on success, or nil+err on failure local function newPegasusServer(opts) diff --git a/rockspecs/pegasus-dev-1.rockspec b/rockspecs/pegasus-dev-1.rockspec index 9aa32b0..059ca40 100644 --- a/rockspecs/pegasus-dev-1.rockspec +++ b/rockspecs/pegasus-dev-1.rockspec @@ -39,6 +39,7 @@ build = { ['pegasus.compress'] = 'src/pegasus/compress.lua', ['pegasus.plugins.compress'] = 'src/pegasus/plugins/compress.lua', ['pegasus.plugins.downloads'] = 'src/pegasus/plugins/downloads.lua', + ['pegasus.plugins.files'] = 'src/pegasus/plugins/files.lua', ['pegasus.plugins.tls'] = 'src/pegasus/plugins/tls.lua', } }