I'm learning Micronaut for our app that will be deployed to AWS Lambda. One of the endpoint needs to return a No Content. I tried different approaches but still not getting no content response.
This one returns 404 Not Found on localhost:8080
@Controller
public class MyController {
@Get
public HttpResponse<Void> save() {
return HttpResponse.noContent();
}
}
Also this one
@Controller
public class MyController {
@Get
@Status(HttpStatus.NO_CONTENT)
public void save() {
}
}
I tried @Post but it returns
com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
@Controller
public class MyController {
@Post
@Status(HttpStatus.NO_CONTENT)
public void save() {
}
}
Can anyone provide a working example. Thank you.
It has something to do with the runtime specified on the build.gradle. I forgot to change it from runtime("lambda")
to runtime("netty")
, that's why testing it locally returns an error response.