freeCodeCamp/guide/russian/certifications/apis-and-microservices/basic-node-and-express/chain-middleware-to-create-.../index.md

21 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
title: Chain Middleware to Create a Time Server
localeTitle: Сетевое ПО Chain для создания сервера времени
---
## Сетевое ПО Chain для создания сервера времени
Подобно последнему вызову, но теперь мы объединяем две функции вместе. Это кажется сложным, но это просто javascript.
Вместо ответа со временем мы можем также добавить строку к запросу и передать ее следующей функции. Это тривиально, но это делает достойный пример. Код выглядит так:
```javascript
app.get("/now", middleware(req, res, next) {
req.string = "example";
next();
},
function (req, res) {
res.send(req.string); // This will display "example" to the user
});
```
[Помогите нашему сообществу расширить эти подсказки и руководства](https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/apis-and-microservices/basic-node-and-express/chain-middleware-to-create-a-time-server/index.md) .