APIHandler: return HTTP/404 when non existing API methods are invoked
Before this change, invoking a non existing API method would return an HTTP/200 response with a JSON payload {"code":3,"message":"no such function"}. This commit changes the HTTP status code to 404, leaving the payload as-is. Before: curl --verbose "http://localhost:9001/api/1/notExisting?apikey=ABCDEF" < HTTP/1.1 200 OK < X-Powered-By: Express [...] {"code":3,"message":"no such function","data":null} After: curl --verbose "http://localhost:9001/api/1/notExisting?apikey=ABCDEF" < HTTP/1.1 404 OK < X-Powered-By: Express [...] {"code":3,"message":"no such function","data":null} Fixes #3546.pull/3726/head
parent
0d61d6bb13
commit
a0579c90db
|
@ -160,7 +160,7 @@ exports.handle = async function(apiVersion, functionName, fields, req, res)
|
||||||
|
|
||||||
// say goodbye if this is an unknown function
|
// say goodbye if this is an unknown function
|
||||||
if (!(functionName in version[apiVersion])) {
|
if (!(functionName in version[apiVersion])) {
|
||||||
// no status code?!
|
res.statusCode = 404;
|
||||||
res.send({code: 3, message: "no such function", data: null});
|
res.send({code: 3, message: "no such function", data: null});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue