New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
404 if I return response.body() #187
Comments
You don't explain how you try to access the resource. Have you tried adding a slash before hello ie. get("/hello", (... |
Yes, I have tried both paths, "hello" and "/hello". When I access http://localhost:4567/hello, I get the 404 in both cases |
The code inside your method is strange, however that doesn't explain the behavior. Are your running it standalone or in another web app server like tomcat? Have you tried just returning "Hello World";? |
If I return any other string, it works fine. If I return the response.body()(which is a String), it gives the 404. I am running this simple test with the built in Jetty container. |
This is because calling response.body() the invocation in ResponseWrapper is not delegated. I'm not sure why this is not done. However, It's not encouraged to use body(string) from Routes since the return value is used. It's supposed to be used from the filters where the return type is Void. |
Clear enough. Reading the http://www.sparkjava.com/readme.html#title4 you get the impression that this is the standard way you define the response body. From code examples thought it is pretty clear that the example I have mentioned is never used and discouraged. You can close this issue if you want. |
Yep, I might need to clarify that section and also fix the bug so it can be used from within Routes. I hope all the other documentation in the README section inspires users to use the return value. |
Hi, why do I get a 404 if I do this?
The text was updated successfully, but these errors were encountered: