mod_http_errors: Add two new config options, http_errors_always_show (show even for...
authorMatthew Wild <mwild1@gmail.com>
Fri, 27 Apr 2012 22:12:30 +0000 (23:12 +0100)
committerMatthew Wild <mwild1@gmail.com>
Fri, 27 Apr 2012 22:12:30 +0000 (23:12 +0100)
plugins/mod_http_errors.lua

index 820bcc2f27366ff643ec8d2b65827efc320f7f95..c7bcbbc1d074b647df6cf54bd837160b6f0e7c0d 100644 (file)
@@ -6,7 +6,8 @@ local codes = require "net.http.codes";
 local termcolours = require "util.termcolours";
 
 local show_private = module:get_option_boolean("http_errors_detailed", false);
-
+local always_serve = module:get_option_boolean("http_errors_always_show", true);
+local default_message = { module:get_option_string("http_errors_default_message", "That's all I know.") };
 local default_messages = {
        [400] = { "What kind of request do you call that??" };
        [403] = { "You're not allowed to do that." };
@@ -59,7 +60,8 @@ end
 
 local function get_page(code, extra)
        local message = messages[code];
-       if message then
+       if always_serve or message then
+               message = message or default_message;
                return (html:gsub("$(%a+)", {
                        title = rawget(codes, code) or ("Code "..tostring(code));
                        message = message[1]:gsub("%%", function ()