How does this behave with routers?
See original GitHub issueHey there, awesome library that removes a lot of hassle, really!
I have this particular use case in which I am releasing a library which expose a Express router, so here is the following use case:
var linkedDataProvider = require("./ldp")
var express = require("express")
var app = express();
app.use('/test', ldp({patch: true}));
Now, the implementation of ldp is as following:
module.exports = function(opts) {
var router = new express.Router();
[...]
router.post("/", postOrPatch);
router.delete("/", deleteObj);
[...]
return router;
}
Now, if I want to include
router.ws(''/", realTime);
How can make this happen?
My ideas are the following
- I require(‘express-ws’)(router) ?
- I have express-ws outside my library, so if you need you can set extra property
- I have to have another function for creating ldp routes like
ldp(route)(app)
Thanks a lot for your time
Issue Analytics
- State:
- Created 9 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
What Is a Router and How Does It Work? - Lifewire
A router is the first line of security from intrusion into a network. Enabling the highest level of security on the router turns...
Read more >What Is A Router And How Does It Work? Latest Blog Posts
A router is responsible for organising communication between computer networks. A router takes data packets from devices and directs them to the ...
Read more >How Does a Router Work? - Cisco
Routers connect computers and other devices to the Internet. A router acts as a dispatcher, choosing the best route for your information to...
Read more >How does a router behave when some of the fragments of a ...
Routers typically do not care about fragmentation. They pass things on exactly ... As such, the router will be unaware of missing fragments....
Read more >Do routers act like switches when devices are connected to it ...
Thus, the concept of a router or forwarder is needed. Hosts in the same network can reach each other directly, if they are...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi,
First of all: I’m flattered that you find this library useful.
I also agree that the feature described here would be a very nice addition, so I’ll have a look at it ASAP. Unfortunately it’s not entirely straightforward to implement support for routers since they don’t have any information on where they are mounted in the application. This means that we don’t know which path to give the
WebSocketServer
when we runrouter.ws('/socket', handler)
. The router could be mounted anywhere in the application.I will try to come up with a (not too hacky) solution here though, and I’ll keep you updated.
This is awesome, thanks! @joepie91 , @HenningM