6

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

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.