How to use the MethodNotAllowedError function from restify

Find comprehensive JavaScript restify.MethodNotAllowedError code examples handpicked from public code repositorys.

21
22
23
24
25
26
27
28
29
30
31
32
33
const ALLOWED_APP_EXTENSIONS = [".zip", ".fma"];


const GCODE_EXTENSIONS = [".nc", ".g", ".gc", ".gcode"];
const OPENSBP_EXTENSIONS = [".sbp", ".sbc"];


var MethodNotAllowedError = errors.MethodNotAllowedError;
var NotAuthorizedError = errors.NotAuthorizedError;
var ResourceNotFoundError = errors.ResourceNotFoundError;


function listify(x) {
fork icon22
star icon52
watch icon0

32
33
34
35
36
37
38
39
40
41
                res.header('Access-Control-Allow-Methods', res.methods.join(', '));
                res.header('Access-Control-Allow-Origin', req.headers.origin);

                return res.send(204);
        } else {
                return res.send(new restify.MethodNotAllowedError());
        }
}

server.on('MethodNotAllowed', unknownMethodHandler);
fork icon3
star icon2
watch icon3

+ 9 other calls in file

66
67
68
69
70
71
72
73
74
75
76
    response.header("Content-type", "application/json charset=UTF-8");
    response.header("Content-length", 0);


    response.send(204);
  } else {
    response.send(new restify.MethodNotAllowedError());
  }
});
//指定根路由返回内容
server.get('/', function (req, res, next) {
fork icon2
star icon0
watch icon0