Hi,
I would like some advice or help in designing a new REST service.
I'm using CXF to serve REST webservices. I already have a custom
interceptors, however I'm not sure how to deal with the following.
Is it possible to 'map' HeaderParams (or FormParam, QueryParam, PathParam)
to custom Java types, instead of a simple string. And eventually answer
something else if the value of the param is not valid.
For example the HTTP Header "Accept-Language" can have several string
values, I would like to map those values to a List<Locale> in order to
write methods like the one below :
@GET
@Path("/check/stuff/{id}")
public CustomAnswer checkStuffAndAnswerInAcceptedLanguage(@PathParam("id")
int id, @HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) List<Locale> locales) {
// business stuff
}
Also if the locales are incorrect then answer with a custom response (in
JSON or XML), I'm not sure if I should use the JAXRS response builder or
rely on a provider (we are using GSon in a provider).
Thanx in advance for your input.
--
Brice