Skip to content

Instantly share code, notes, and snippets.

@sean3z
Created April 13, 2017 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sean3z/94af90df7ad2aaa9f98c017039784d6b to your computer and use it in GitHub Desktop.
Save sean3z/94af90df7ad2aaa9f98c017039784d6b to your computer and use it in GitHub Desktop.
Example Restify route
app.get('/hello/:name/:age([0-9]+)/:cool(true|false)', (req, res, next) => {
let {name, age, cool} = req.params;
cool = (cool === 'true');
age = parseInt(age);
if (cool) {
res.send(`You're a cool ${age} year old, ${name}`);
} else {
res.send(`${name}, we need to talk about your coolness.`);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment