Skip to content

Commit

Permalink
Added 404 code for single news getting
Browse files Browse the repository at this point in the history
  • Loading branch information
N1ghtF1re committed May 12, 2019
1 parent 1507f81 commit 25d3984
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/kotlin/men/brakh/bsuirapi/controller/NewsServlet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class NewsServlet : HttpServlet() {
val multiParams: Map<String, Array<String>> = req.parameterMap

if("id" in params) {
resp.writer.write(newsRepo.findById(params["id"]!!.toLong())?.toJson())
val news = newsRepo.findById(params["id"]!!.toLong())
news?.let { resp.writeJson(it) } ?: resp.writeError("News not found", 404)
return
}

Expand Down

0 comments on commit 25d3984

Please sign in to comment.