Software /
code /
prosody
Diff
plugins/mod_http.lua @ 4724:a8c234332258
mod_http: Allow a route value to be static data rather than a handler function
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 27 Apr 2012 19:02:36 +0100 |
parent | 4721:1c6c4c53f08a |
child | 4736:3514338c59c3 |
line wrap: on
line diff
--- a/plugins/mod_http.lua Fri Apr 27 18:54:51 2012 +0100 +++ b/plugins/mod_http.lua Fri Apr 27 19:02:36 2012 +0100 @@ -51,7 +51,10 @@ for key, handler in pairs(event.item.route or {}) do local event_name = get_http_event(host, app_path, key); if event_name then - if event_name:sub(-2, -1) == "/*" then + if type(handler) ~= "function" then + local data = handler; + handler = function () return data; end + elseif event_name:sub(-2, -1) == "/*" then local base_path = event_name:match("/(.+)/*$"); local _handler = handler; handler = function (event)