当前位置: 动力学知识库 > 问答 > 编程问答 >

express - What is a pass-through request?

问题描述:

This is spoken in the context of a guide on express.js. Here is the quote:

Static middleware enables pass-through requests for static assets.

Googling doesn't yield a definition like I thought it would.

网友答案:

I think "pass-through" in this context means that static files on disk "pass through" express without any processing or modification and are sent directly to the browser, in contrast to dynamic requests which involve generating new and dynamic HTML in response to a browser request (using templates and databases, perhaps).

网友答案:

For example, we have this code at http://example.org

app.use(express.static(__dirname + '/public'));
app.get('*',function(req, res){
  res.send('Hello');
});

For example, we open by browser the url http://example.org/somefile.txt

if there is file of somefile.txt in folder of public/ , it is returned, but if the file doesn't exists, the request is passed to other controllers, in this case to app.get('*',...)

So, the client recieves the response with Hello

分享给朋友:
您可能感兴趣的文章:
随机阅读: