Skip to content

Commit

Permalink
fix: Correct 404 and Content-Type Issues in MQTT Version Endpoint (#837)
Browse files Browse the repository at this point in the history
Signed-off-by: Parham Alvani <parham.alvani@gmail.com>
  • Loading branch information
1995parham authored and nmarcetic committed Sep 5, 2019
1 parent 640dfb7 commit 115d94b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mqtt/aedes/mqtt.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,13 @@ esclient.on('error', function(err) {
function startWs() {
var server = http.createServer();
server.on('request', (req, res) => {
res.setHeader('Content-Type', 'application/json');
if (req.url === '/version') {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain; charset=utf-8');
res.end(`{"service":"mqtt-adapter","version":"${version}"}`);
}
res.statusCode = 404;
res.end('{"service":"mqtt-adpater", "message": "not found"}')
});
websocket.createServer({server: server}, aedes.handle);
server.listen(config.ws_port);
Expand Down

0 comments on commit 115d94b

Please sign in to comment.