Skip to content

Instantly share code, notes, and snippets.

@kristofsajdak
Forked from dclucas/defineRoute.groovy
Last active August 29, 2015 14:20
Show Gist options
  • Save kristofsajdak/d086b558b09f59455891 to your computer and use it in GitHub Desktop.
Save kristofsajdak/d086b558b09f59455891 to your computer and use it in GitHub Desktop.
def defineRoute(routeBuilder) {
routeBuilder.categories {
schema {
properties {
name {
type string,
description "a name"
}
links {
brand "brands"
}
}
required ['name']
name "Category"
}
get { req, res ->
// any kind of dynamic validation, custom authorization can be done in line
"people.get logic goes here"
}
.document { docs -> docs.summary = "Overridden summary for post"; doc }
post { req, res, data ->
"people.get logic goes here"
}
"{id}" {
get { req, res ->
"people/{id}/"
}
patch { req, res, data ->
"people/{id}/"
}
delete { req, res ->
"people/{id}/"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment