Skip to content

Instantly share code, notes, and snippets.

@aaronpowell
Last active August 29, 2015 14:01
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 aaronpowell/7df5e1fd1a7967259d38 to your computer and use it in GitHub Desktop.
Save aaronpowell/7df5e1fd1a7967259d38 to your computer and use it in GitHub Desktop.
Express DLS
let get = macro {
rule { $path:lit $do $res:lit } => {
app.get($path, function (req, res) {
res.$do($res);
});
}
rule { $path:lit $do:ident($sc:lit) $res:lit } => {
app.get($path, function (req, res) {
res.$do($res);
res.status($sc);
});
}
rule { $path:lit with ($req:ident $res:ident) { $body ... } } => {
app.get($path, function ($req, $res) {
$body ...
});
}
}
get '/' with (req res) {
req.send('Hello');
}
get '/404' render(404) 'not-found'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment