Skip to content

Commit 7329330

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

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

middleware-exercises/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ app.get("/", (req, res) => res.status(200).send("Server is running"));
88

99
app.post("/", (req, res) => {
1010
req.username = req.headers["x-username"] ?? null;
11-
next();
11+
const message = req.username
12+
? `You are authenticated as ${req.username}`
13+
: "You are not authenticated";
14+
res.status(200).send(message);
1215
});
1316

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

0 commit comments

Comments
 (0)