Created
July 24, 2016 22:40
-
-
Save Noxville/c78559610be12aabc110cc8f9aa35025 to your computer and use it in GitHub Desktop.
RestFilters.groovy
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
package twopee | |
import grails.converters.JSON | |
import groovy.json.JsonOutput | |
class RestFilters { | |
def filters = { | |
all(controller: "(restRanking|restTeam|restLivegames|restModel|restMatch|restEvent|restView|restElo|restGlicko)", action:"") { | |
before = { } | |
after = { model -> | |
String resp = (model?.alreadyJson) ? model.data : (model as JSON) | |
if (params.prettyprint) { | |
resp = JsonOutput.prettyPrint(resp.toString()) | |
} | |
if (params.callback) { | |
resp = params.callback + "(" + resp + ")" | |
} | |
render (contentType: "application/json", text: resp) | |
return false | |
} | |
afterView = { } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment