Skip to content

Instantly share code, notes, and snippets.

@spinscale
Created February 5, 2013 10:42
Show Gist options
  • Save spinscale/4713657 to your computer and use it in GitHub Desktop.
Save spinscale/4713657 to your computer and use it in GitHub Desktop.
def get(String path, Closure ... closures) {
spark.Spark.get(createClosureBasedRouteForPath(path, closures))
}
private Route createClosureBasedRouteForPath(String path, Closure ... closures) {
new Route(path) {
def handle(Request request, Response response) {
closures*.delegate = this
return closures*.call(request, response).findAll { it }.join()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment