Permalink
Browse files

Merge pull request #21 from chochos/master

'register' closure for custom verbs
  • Loading branch information...
2 parents 93888f5 + 1b67d57 commit e1d8b1acee1f1aea37c197ed2a029a1fee433744 @Vossy Vossy committed Jan 12, 2012
View
2 build.gradle
@@ -10,7 +10,7 @@ repositories {
}
dependencies {
- groovy group: 'org.codehaus.groovy', name: 'groovy', version: '1.8.3'
+ groovy group: 'org.codehaus.groovy', name: 'groovy', version: '1.8.4'
compile group: 'javax.servlet', name: 'servlet-api', version: '2.5'
compile group: 'org.json', name: 'json', version: '20090211'
View
9 src/main/groovy/com/bleedingwolf/ratpack/RatpackApp.groovy
@@ -66,6 +66,14 @@ class RatpackApp {
register('DELETE', path, handler)
}
+ def register = { method, path, handler ->
+ if (method instanceof List) {
+ register(method as List, path, handler)
+ } else {
+ register(method as String, path, handler)
+ }
+ }
+
public void prepareScriptForExecutionOnApp(String scriptName){
prepareScriptForExecutionOnApp(new File(scriptName))
}
@@ -80,6 +88,7 @@ class RatpackApp {
binding.setVariable('put', app.put)
binding.setVariable('delete', app.delete)
binding.setVariable('set', app.set)
+ binding.setVariable('register', app.register)
gse.run scriptFile.name, binding
}
}
View
2 src/main/groovy/com/bleedingwolf/ratpack/RatpackRequestDelegate.groovy
@@ -47,7 +47,7 @@ public class RatpackRequestDelegate {
if (!response.containsHeader("Content-Type")) {
contentType("application/json")
}
- new JSONObject(o).toString()
+ new JSONObject(o).toString()
}
}

0 comments on commit e1d8b1a

Please sign in to comment.