diff --git a/lib/middleware.js b/lib/middleware.js index 4a64297..fc03acf 100644 --- a/lib/middleware.js +++ b/lib/middleware.js @@ -4,11 +4,11 @@ const express = require('express'); const bodyParser = require('body-parser'); const stream = require('stream'); -function Middleware(logger, messageValidatorService) { +function Middleware(logger, messageValidatorService, path) { this._logger = logger; this._stream = this._createStream(); this._buffer = null; - + this._path=path; this._app = express(); this._app.use(bodyParser.text({ type: "*/*" })); @@ -26,12 +26,12 @@ Middleware.prototype.getStream = function() { Middleware.prototype._configureEndpoints = function() { const self = this; - this._app.get("/ping", (request, response) => { + this._app.get(self._path+"/ping", (request, response) => { response.send("pong"); response.end(); }); - this._app.post("/", (request, response) => { + this._app.post(self._path+"/", (request, response) => { self._logger.debug("Request data:", request.body); self._stream.push(request.body); diff --git a/lib/viber-bot.js b/lib/viber-bot.js index 201c612..443a7f8 100644 --- a/lib/viber-bot.js +++ b/lib/viber-bot.js @@ -56,7 +56,7 @@ function ViberBot(loggerOrConfiguration, configuration) { this._logger = logger; this._client = new ViberClient(this._logger, this, API_URL, configuration.registerToEvents || SUBSCRIBED_EVENTS); - this._middleware = new Middleware(this._logger, new MessageValidator(this._logger, this.authToken)); + this._middleware = new Middleware(this._logger, new MessageValidator(this._logger, this.authToken),configuration.path); this._messageFactory = new MessageFactory(this._logger); this._regexMatcherRouter = new RegexMatcherRouter(this._logger); this._callbacks = { [EventConsts.CONVERSATION_STARTED]: []};