Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Express middleware to log a JSON request as a cURL command. Inspired by Chrome's "Copy as cURL" feature.
// After body-parsing middleware...
app.use(function(req, res, next) {
console.log(
"curl '%s://%s%s' -X %s -H 'Content-Type: %s' -d '%s'",
req.protocol,
req.get("host"),
req.originalUrl,
req.method,
req.get("Content-Type"),
JSON.stringify(req.body)
);
next();
});
@sadiqulngn

This comment has been minimized.

Copy link

sadiqulngn commented Jul 1, 2016

hi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.