Skip to content

Commit

Permalink
fix(Route): route method define fix
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Websocket `.ws` method now uses default behavior of uWebSockets.js
  • Loading branch information
dalisoft committed Jun 4, 2021
1 parent 80a5312 commit ebf0e22
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions src/Route.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export default class Route {
: path === '/'
? this._basePath
: this._basePath + path;
this._app._router.all(routePath, handler);
this._app._router.on('ANY', routePath, handler);
} else {
this._routers.push({ method: httpMethods, path, handler });
this._routers.push({ method: 'ANY', path, handler });
}
});

Expand Down Expand Up @@ -65,18 +65,7 @@ Route.prototype.publish = function publish(topic, message, isBinary, compress) {
);
};

Route.prototype.ws = function wsExpose(path, handler, options = {}) {
if (typeof handler === 'object') {
options = handler;
handler = null;
}

if (typeof options.open === 'function') {
this._ws.push({ path, handler: options });
return this;
}

this._ws.push({ path, handler, options });

Route.prototype.ws = function wsExpose(path, options) {
this._ws.push({ path, options });
return this;
};

0 comments on commit ebf0e22

Please sign in to comment.