Created
February 5, 2013 10:44
-
-
Save spinscale/4713671 to your computer and use it in GitHub Desktop.
spark-groovy-jrebel-formats
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def jsonClosure = { Request request, Response response -> | |
if (request.contentType() == 'application/json') | |
json([name: request.attribute('name')]) | |
} | |
def xmlClosure = { Request request, Response response -> | |
if (request.contentType() == 'application/xml') | |
'<name>' + request.attribute('name') + '</name>\n' | |
} | |
get "/format", { Request request, Response response -> | |
request.attribute("name", "some cool name") | |
}, jsonClosure, xmlClosure |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment