Open cesarcastmore opened 8 years ago
Hi,
Normally you are supposed to return a POJO as entity and let Lambada serialize that to JSON as it is shown here: https://github.com/lambadaframework/lambadaframework-boilerplate/blob/master/src/main/java/org/lambadaframework/example/controllers/ExampleController.java#L29 For now you can do like that to resolve the issue.
But your request is also legitimate, in the next release I'll try to support this.
is it possible to build an object Respose like this?
@GET public Response get() { ResponseBuilder builder = Response.ok("{\"name\" : \"cesar\" }"); return builder.build(); }
When I invoked my service, Lambda was sending a String. "{\"name\" : \"cesar\" }" But I was waiting a json {"name" : "cesar" }
When I am adding the MediaType, I get an exception on Lambda @GET public Response get() { ResponseBuilder builder = Response.ok("{\"name\" : \"cesar\" }"); builder.type(MediaType.APPLICATION_JSON); return builder.build(); }
java.lang.ClassCastException: javax.ws.rs.core.MediaType cannot be cast to java.lang.String at org.lambadaframework.runtime.models.Response.buildFromJAXRSResponse(Response.java:44) at org.lambadaframework.runtime.Handler.handleRequest(Handler.java:63) at org.lambadaframework.runtime.Handler.handleRequest(Handler.java:14) at lambdainternal.EventHandlerLoader$PojoHandlerAsStreamHandler.handleRequest(EventHandlerLoader.java:370) at lambdainternal.EventHandlerLoader$2.call(EventHandlerLoader.java:972) at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:231) at lambdainternal.AWSLambda.(AWSLambda.java:59)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at lambdainternal.LambdaRTEntry.main(LambdaRTEntry.java:93)