Skip to content

Commit

Permalink
Remove remy from global scope
Browse files Browse the repository at this point in the history
  • Loading branch information
Etiene committed Feb 15, 2016
1 parent 999a995 commit ef75596
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 11 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ Remy was developed as part of [Sailor](https://github.com/Etiene/sailor), a Lua-
## Usage #

``` lua
require "remy"
require "string"
local remy = require "remy"

function handle(r)
r.content_type = "text/plain"
Expand Down
10 changes: 8 additions & 2 deletions src/remy.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
-- Remy 0.2.9
-- Remy 0.2.10
-- Copyright (c) 2014-2015 Felipe Daragon
-- License: MIT (http://opensource.org/licenses/mit-license.php)
--
-- Remy runs Lua-based web applications in alternative web server
-- environments that allow to run Lua code.

remy = {
local remy = {
MODE_AUTODETECT = nil,
MODE_CGILUA = 0,
MODE_MOD_PLUA = 1,
Expand All @@ -14,6 +14,8 @@ remy = {
MODE_LIGHTTPD = 4
}

local forced_mode = nil

local emu = {}

-- The values below will be updated during runtime
Expand Down Expand Up @@ -124,6 +126,7 @@ end
-- Detects the Lua environment
function remy.detect(native_request)
local mode = nil
if forced_mode then return forced_mode end
if cgilua ~= nil then
mode = remy.MODE_CGILUA
elseif ngx ~= nil then
Expand All @@ -133,6 +136,7 @@ function remy.detect(native_request)
if env["pLua-Version"] ~= nil then
mode = remy.MODE_MOD_PLUA
end
-- Note: lighty is not a package so package.loaded.lighty ~= nil will not work
elseif lighty ~= nil then
mode = remy.MODE_LIGHTTPD
elseif native_request ~= nil and type(native_request.query_param) == "function" then
Expand Down Expand Up @@ -176,3 +180,5 @@ function remy.sha1(str)
local sha1 = require "sha1"
return sha1(str)
end

return remy
6 changes: 4 additions & 2 deletions src/remy/cgilua.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
-- Copyright (c) 2014 Felipe Daragon
-- License: MIT

require "base64"
local base64 = require "base64"
local cgilua = require "cgilua"
local remy = require "remy"

-- TODO: implement all functions from mod_lua's request_rec
local request = {
Expand Down Expand Up @@ -125,4 +127,4 @@ function M.finish(code)
end
end

return M
return M
3 changes: 2 additions & 1 deletion src/remy/lwan.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
-- Copyright (c) 2014 Leandro Pereira <[email protected]>
-- License: MIT

require "base64"
local base64 = require "base64"
local remy = require "remy"

local lwan = {}
lwan.query_param_table = function(req)
Expand Down
7 changes: 4 additions & 3 deletions src/remy/mod_magnet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
-- Copyright (c) 2015 Felipe Daragon
-- License: MIT

require "base64"
local base64 = require "base64"
local remy = require "remy"

local utils = {}

Expand Down Expand Up @@ -50,7 +51,7 @@ function M.init()
r.args = lighty.env["uri.query"]
--r.args = remy.splitstring(lighty.env['request.uri'],'?')
r.banner = M.mode
r.basic_auth_pw = pass
r.basic_auth_pw = pass
r.canonical_filename = filename
r.context_document_root = lighty.env["physical.doc-root"]
r.document_root = lighty.env["physical.doc-root"]
Expand All @@ -76,4 +77,4 @@ function M.finish(code)
lighty.content = { remy.responsetext }
end

return M
return M
2 changes: 2 additions & 0 deletions src/remy/mod_plua.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
-- Copyright (c) 2014 Felipe Daragon
-- License: MIT

local remy = require "remy"

-- TODO: implement all functions from mod_lua's request_rec
local request = {
-- ENCODING/DECODING FUNCTIONS
Expand Down
5 changes: 4 additions & 1 deletion src/remy/nginx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
-- Copyright (c) 2014 Felipe Daragon
-- License: MIT

local ngx = require "ngx"
local remy = require "remy"

-- TODO: implement all functions from mod_lua's request_rec
local request = {
-- ENCODING/DECODING FUNCTIONS
Expand Down Expand Up @@ -38,7 +41,7 @@ function M.init()
r.method = ngx.var.request_method
r.args = remy.splitstring(ngx.var.request_uri,'?')
r.banner = M.mode.."/"..ngx.var.nginx_version
r.basic_auth_pw = pass
r.basic_auth_pw = pass
r.canonical_filename = filename
r.context_document_root = ngx.var.document_root
r.document_root = r.context_document_root
Expand Down

0 comments on commit ef75596

Please sign in to comment.