Reputation: 67862
Is there any way to modify request.format
in a filter or controller?
I'm getting groovy.lang.GroovyRuntimeException: Cannot set read-only property: format
no matter what I try. I need to manage my own content type negotiation in a request-neutral way, so a filter seems like the way to go.
Upvotes: 0
Views: 431
Reputation: 11035
The request.format call is handled by the RequestMimeTypesApi#getFormat method. I have not tested this, but think the following would work in a filter or controller:
import org.codehaus.groovy.grails.web.servlet.GrailsApplicationAttributes
....
request[GrailsApplicationAttributes.CONTENT_FORMAT] = format
Upvotes: 1