exports.AllowedMethods = function (app, methods) {
    return function (env) {
        if (methods.indexOf(env.REQUEST_METHOD) === -1) return {
            status : 405,
            headers : {"Content-Type":"text/plain"},
            body : [
                "Method Not Allowed: "+env["REQUEST_METHOD"] +"\n"+
                "Allowed methods: "+methods.join(",")
            ]
        };
        return app(env);
    };
};
            
exports.AllowedMethods = function (app, methods) {
    return function (env) {
        if (methods.indexOf(env.REQUEST_METHOD) === -1) return {
            status : 405,
            headers : {
                "Content-Type" : "application/json",
                "Allow" : methods.join(",")
            },
            body : [JSON.stringify({
                error : "Method Not Allowed: "+env["REQUEST_METHOD"],
                allow : methods
            })]
        };
        return app(env);
    };
};
            
Make the 405 response more valid, and also JSON.