X-Git-Url: https://git.josue.xyz/?p=VSoRC%2F.git;a=blobdiff_plain;f=node_modules%2Fexpress-ws%2Fexamples%2Fparams.js;fp=node_modules%2Fexpress-ws%2Fexamples%2Fparams.js;h=b982a59afb4f7cf818fc9f2386ae9e5e81d95a07;hp=0000000000000000000000000000000000000000;hb=2b1de44527123fab80901384e0f374367500ced8;hpb=e79e4a5a87f3e84f7c1777f10a954453a69bf540 diff --git a/node_modules/express-ws/examples/params.js b/node_modules/express-ws/examples/params.js new file mode 100644 index 0000000..b982a59 --- /dev/null +++ b/node_modules/express-ws/examples/params.js @@ -0,0 +1,26 @@ +var express = require('express'); +var expressWs = require('..'); + +var expressWs = expressWs(express()); +var app = expressWs.app; + +app.param('world', function (req, res, next, world) { + req.world = world || 'world'; + return next(); +}); + +app.get('/hello/:world', function(req, res, next){ + console.log('hello', req.world); + res.end(); + next(); +}); + +app.ws('/hello/:world', function(ws, req, next) { + ws.on('message', function(msg) { + console.log(msg); + }); + console.log('socket hello', req.world); + next(); +}); + +app.listen(3000)