Stefan Kendall
Stefan Kendall

Reputation: 67862

Grails change request.format?

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

Answers (1)

John Wagenleitner
John Wagenleitner

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

Related Questions