Created
October 15, 2014 14:30
-
-
Save jalada/fda3dc2d14d05efe97ba to your computer and use it in GitHub Desktop.
Status Codes As A Service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var app = express(); | |
app.get('/:status_code', function (req, res) { | |
if (req.params.status_code.match(/^\d{3}$/)) { | |
res.status(req.params.status_code).send(''); | |
} else { | |
res.status(500).send('Not a code'); | |
} | |
}); | |
var server = app.listen(process.env.PORT, function () { | |
console.log("Yo dawg."); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment