Hi,
I'm currently evaluating Jooby and I like it so far, good work!! I may have some more questions/suggestions if I decide to use it for a real project and if you don't mind... But here's my first one! :
I would use MVC routes, mainly because of the Swagger support for them. But I also like to have full control over what I send as a response, when this is needed. So I was happy to see that Jooby automatically injects Request and Response on a route endpoint!
For example :
@GET
@Path("/test")
public void test(Request request, Response response) throws Exception {
response.status(418);
response.send("test!");
response.end();
}
But when I do that, I get an error because, after the method returns, Jooby tries to write another status code by itself, even if the headers are already sent :
[2015-12-26 15:46:14,810]-[utow task-2] ERROR org.jooby.spi.HttpHandler - execution of err handler resulted in exception
java.lang.IllegalStateException: UT000002: The response has already been started
at io.undertow.server.HttpServerExchange.setStatusCode(HttpServerExchange.java:1353) ~[undertow-core-1.3.9.Final.jar:1.3.9.Final]
at io.undertow.server.HttpServerExchange.setResponseCode(HttpServerExchange.java:1328) ~[undertow-core-1.3.9.Final.jar:1.3.9.Final]
at org.jooby.internal.undertow.UndertowResponse.statusCode(UndertowResponse.java:108) ~[jooby-undertow-0.11.2.jar:na]
at org.jooby.internal.ResponseImpl.status(ResponseImpl.java:219) ~[jooby-0.11.2.jar:na]
at org.jooby.internal.HttpHandlerImpl.handleErr(HttpHandlerImpl.java:250) [jooby-0.11.2.jar:na]
at org.jooby.internal.HttpHandlerImpl.handle(HttpHandlerImpl.java:197) [jooby-0.11.2.jar:na]
at org.jooby.internal.undertow.UndertowHandler.handleRequest(UndertowHandler.java:59) [jooby-undertow-0.11.2.jar:na]
....
So is it possible to control the response by ourself inside a MVC route or this is not a recommended thing to do?
Also, I have Jackson registered :
Is there a way to bypass this filter for a particular route? In my previous example, "
test!" is not send as plain/text because of Jackson...
Will all routes registered after a filter like Jackson
inevitably be affected, without the possibility to bypass the filter?Thanks you!
Julien