opened
prashcr
username_0
This worked really nice on an express `app`, and I want to be able to use it on a `router`. I kept getting a `400` error when I tried it on a router.
Is it possible to use this on an express router?
issue
created
olalonde
username_1
I'm not sure it works. Can you give some example code?
comment
created
prashcr
username_0
```
var express = require('express');
var http = require('http');
var ws = require('ws');

var handleUpgrade = require('express-websocket');

var app = express();
var server = http.createServer(app);
var wss = new ws.Server({ noServer: true });
var thing = express.Router();

app.use('/thing', thing)

thing.use('/websocket', function (req, res, next) {
  res.websocket(function (ws) {
    // Optional callback
    ws.send('hello');
  });
});

server.on('upgrade', handleUpgrade(app, wss));

server.listen(3000);
```
comment
created
olalonde
username_1
So `http://localhost:3000/thing/websocket` doesn't open a websocket connection? weird, I'll have to check this later, I would have expected this to work.
comment
created
prashcr
username_0
Never mind, I think I made a mistake in my code elsewhere, because it does work when I tested it with a simple example just now.
comment
closed
prashcr
username_0
issue