Skip to content

Instantly share code, notes, and snippets.

@abdulbasitkay
Created May 4, 2017 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abdulbasitkay/ca443dfc80e12ad5bcba91fe2274f0f5 to your computer and use it in GitHub Desktop.
Save abdulbasitkay/ca443dfc80e12ad5bcba91fe2274f0f5 to your computer and use it in GitHub Desktop.
Question Resource with null check.
@Path("questions/")
public class QuestionResource {
@GET
@Path("{id}")
@Produces("application/json")
Response getQuestion(@PathParam("id") String questionId) {
QuestionDto question = questionService.getQuestionById(questionId);
if (question == null) {
return Response.status(NOT_FOUND).build();
}
return Response.status(OK).entity(question).build();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment