From ab4dc8e884b96bb02cde3c4b842a6237c173e49e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= Date: Tue, 10 Jul 2012 19:53:03 +0000 Subject: Upgrade to new Hathaway API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Asbjørn Sloth Tønnesen --- web/labitrackd.lua | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/web/labitrackd.lua b/web/labitrackd.lua index 6a14782..1f25371 100755 --- a/web/labitrackd.lua +++ b/web/labitrackd.lua @@ -168,11 +168,11 @@ local htmlpage = sendfile('text/html; charset=UTF-8', 'pub/index.html') GET('/', htmlpage) GET('/browse', htmlpage) -MATCH('^/browse/(%d+)$', htmlpage) +GETM('^/browse/(%d+)$', htmlpage) GET('/recent', htmlpage) GET('/about', htmlpage) -MATCH('^/view/(%d+)$', htmlpage) -MATCH('^/edit/(%d+)$', htmlpage) +GETM('^/view/(%d+)$', htmlpage) +GETM('^/edit/(%d+)$', htmlpage) GET('/js/corelibs.min.js', sendfile_js('js/dist/corelibs.min.js')) GET('/js/corelibs.src.js', sendfile_js('js/dist/corelibs.src.js')) @@ -192,11 +192,7 @@ GET('/css/labitrack.css', sendfile_css('css/dist/labitrack.min.css')) GET('/favicon.ico', sendfile('image/x-icon', 'pub/favicon.ico')) -MATCH('^/browse/(%d+).json$', function(req, res, since) - if req.method ~= 'HEAD' and req.method ~= 'GET' then - return hathaway.method_not_allowed(req, res) - end - +GETM('^/browse/(%d+).json$', function(req, res, since) set_json_nocache_headers(res) res:add('{"count": %d, "objects":', count()); @@ -248,14 +244,9 @@ local function save_or_update(req, res) end POST('/o', save_or_update) +PUTM('^/o/(%d+).json$', save_or_update) -MATCH('^/o/(%d+).json$', function(req, res, id) - if req.method == 'PUT' then - return save_or_update(req, res) - elseif req.method ~= 'HEAD' and req.method ~= 'GET' then - return hathaway.method_not_allowed(req, res) - end - +GETM('^/o/(%d+).json$', function(req, res, id) set_json_nocache_headers(res) qr = db:run('get', id) -- cgit v1.2.1