Skip to content

Commit 48ec800

Browse files
committed
X-Username header
1 parent 0ffaba6 commit 48ec800

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

middleware-exercises/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ const app = express();
44

55
app.use(express.json());
66

7-
app.get("/", (req, res) => res.status(200).send("Hello World!"));
7+
app.get("/", (req, res) => res.status(200).send("Server is running"));
8+
9+
app.post("/", (req, res) => {
10+
req.username = req.headers["x-username"] ?? null;
11+
next();
12+
});
813

914
app.listen(3000, () => console.log("Server is running on port 3000"));

0 commit comments

Comments
 (0)