I'm working on the following legacy code:
var express = require('express');
var app = express.createServer();
app
.use('/run!', getUrl('app.sys', '/run'))
.use('/stat', getUrl('app.sys'))
I'm having troubles finding documentation for the "use" method. I found some usage examples but in all of them it appeared to be getting one argument and here it gets 2. Could you please help me figure out what is the meaning of the use statement here?
Thanks, Li
app.use means that you will execute a middleware in the order that you give it on the program.
In your example getUrl is the middleware and the string you have as first parameter is a path. So only with that path or 'url' the middleware will be executed.
Not sure tough what getUrl function does there.
If you want to read more about "use" try the official documentation.
http://expressjs.com/api.html#app.use
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With