summaryrefslogtreecommitdiffstats
path: root/lem/hathaway.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lem/hathaway.lua')
-rw-r--r--lem/hathaway.lua35
1 files changed, 18 insertions, 17 deletions
diff --git a/lem/hathaway.lua b/lem/hathaway.lua
index 6d4e2da..b23934c 100644
--- a/lem/hathaway.lua
+++ b/lem/hathaway.lua
@@ -50,28 +50,28 @@ do
local lookup = {}
M.lookup = lookup
- function M.GET(uri, handler)
- local path = lookup[uri]
- if path then
- path['HEAD'] = handler
- path['GET'] = handler
+ function M.GET(path, handler)
+ local entry = lookup[path]
+ if entry then
+ entry['HEAD'] = handler
+ entry['GET'] = handler
else
- path = {
+ entry = {
['HEAD'] = handler,
['GET'] = handler,
}
- lookup[uri] = path
+ lookup[path] = entry
end
end
do
local function static_setter(method)
- return function(uri, handler)
- local path = lookup[uri]
- if path then
- path[method] = handler
+ return function(path, handler)
+ local entry = lookup[path]
+ if entry then
+ entry[method] = handler
else
- lookup[uri] = { [method] = handler }
+ lookup[path] = { [method] = handler }
end
end
end
@@ -137,10 +137,11 @@ do
end
local function handler(req, res)
- local method, uri, version = req.method, req.uri, req.version
- local path = lookup[uri]
- if path then
- local handler = path[method]
+ local method, path, version = req.method, req.path, req.version
+
+ local entry = lookup[path]
+ if entry then
+ local handler = entry[method]
if handler then
handler(req, res)
else
@@ -155,7 +156,7 @@ do
M.not_found(req, res)
break
end
- until check_match(entry, req, res, uri:match(entry[1]))
+ until check_match(entry, req, res, path:match(entry[1]))
end
end