play-jaxrs
play-jaxrs copied to clipboard
@QueryParam for integer types throws exception
I'm trying to use @QueryParam annotation for integer type for example, and get a cast exception.
public Result index(@QueryParam("id") Option<Integer> idParam){
Integer id = idParam.get(); // here will throw the exception
}
I think that for other types throws exception.
P.S. I think that in the case of really type casting errors instance of Option need to return null.
Basically, there is no special treatment for different types. URL is parsed as String
right now. So QueryParam
needs to be Option<String>
Also, this is from the readme: "the captured field can only be a String i.e."
Sometimes it's not convenient for using. Also, JAX-RS Spec describes how convert string values to other basic types, from spec:
Be a primitive type Have a static method named valueOf or fromString that accepts a single String argument (see, for example, Integer.valueOf(String)) Have a constructor that accepts a single String argument
I see that play-jaxrs does not support all features of the specification, but it might be convenient to use.
unfortunately, play-jaxrs
supports only a subset of the spec right now. Depending on my schedule I will try to fill the gap, in the meantime pull requests are welcome :-)