1
0
mirror of https://github.com/mainflux/mainflux.git synced 2025-04-27 13:48:49 +08:00

NOISSUE - Add version endpoint to MQTT adapter (#816)

* Add version endpoint to MQTT adapter

Expose CoAP version endpoint in the default docker-compose.

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>

* Use /tcp insted of implicit protocol name

Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
This commit is contained in:
Dušan Borovčanin 2019-08-14 01:07:11 +02:00 committed by Drasko DRASKOVIC
parent 19834dfc51
commit 5c924bd5a3
2 changed files with 10 additions and 0 deletions

View File

@ -256,6 +256,7 @@ services:
MF_JAEGER_URL: ${MF_JAEGER_URL}
ports:
- ${MF_COAP_ADAPTER_PORT}:${MF_COAP_ADAPTER_PORT}/udp
- ${MF_COAP_ADAPTER_PORT}:${MF_COAP_ADAPTER_PORT}/tcp
networks:
- mainflux-base-net

View File

@ -5,6 +5,8 @@
'use strict';
const version = '0.9.0';
var http = require('http'),
redis = require('redis'),
net = require('net'),
@ -109,6 +111,13 @@ esclient.on('error', function(err) {
// MQTT over WebSocket
function startWs() {
var server = http.createServer();
server.on('request', (req, res) => {
if (req.url === '/version') {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain; charset=utf-8');
res.end(`{"service":"mqtt-adapter","version":"${version}"}`);
}
});
websocket.createServer({server: server}, aedes.handle);
server.listen(config.ws_port);
return server;