mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
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.
This commit is contained in:
parent
0d61d6bb13
commit
a0579c90db
1 changed files with 1 additions and 1 deletions
|
@ -160,7 +160,7 @@ exports.handle = async function(apiVersion, functionName, fields, req, res)
|
|||
|
||||
// say goodbye if this is an unknown function
|
||||
if (!(functionName in version[apiVersion])) {
|
||||
// no status code?!
|
||||
res.statusCode = 404;
|
||||
res.send({code: 3, message: "no such function", data: null});
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue