1
0
Fork 0
mirror of https://github.com/kou029w/http-echo.git synced 2025-01-18 08:05:06 +00:00

feat: pretty response format

This commit is contained in:
Nebel 2020-03-24 14:12:03 +09:00
parent ba5bdc8e09
commit 201e67c4f1

View file

@ -4,9 +4,8 @@ const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(express.raw({ type: "*/*" }));
app.set("json spaces", 2);
app.all("/*", function(req, res) {
app.set("json spaces", req.path === "/pretty" ? 2 : null);
res.json({
headers: req.headers,
body: req.body.length > 0 ? req.body.toString() : null,