Closed confile closed 10 years ago
Did you try with something like the following?
@Provider
@Consumes("application/json")
class UserDtoReader extends MessageBodyReaderSupport<UserDto> {
@Override
public UserDto readFrom(MultivaluedMap<String, String> httpHeaders,
InputStream entityStream) throws IOException,
WebApplicationException {
return new JsonSlurper().parse(new InputStreamReader(entityStream))
}
}
PS: Please also note you missed the @javax.ws.rs.ext.Provider annotation on the reader. It is needed as per https://github.com/krasserm/grails-jaxrs/wiki/Advanced-Features#custom-providers
@davidecavestro Great it works perfect thank you. I think it would be helpful, if you add the method as an example to your documentation.
Just added it to the wiki at http://github.com/krasserm/grails-jaxrs/wiki/Advanced-Features#further-entity-provider-support Cheers Davide
great thank you
I want to use the Grails-jaxrs plugin to implement a custom MessageBodyReaderSupport to read a UserDto class from a client.
How do I have to implement the UserDtoReader in order to get an instance of the UserDto?
This is my UserDto class:
This is my UserDtoReader class: