feat: return distinct 'draft' error for draft post detail requests
Previously the API returned 'not_found' for both missing and draft posts. Now draft posts return a specific 'draft' error code so API consumers can distinguish between the two cases and show an appropriate message.
This commit is contained in:
@@ -28,7 +28,8 @@ module Volumen
|
||||
|
||||
app.get "/api/volumen/posts/:slug" do
|
||||
post = store.find(params["slug"], lang: params["lang"])
|
||||
halt(404, json("error" => "not_found")) if post.nil? || post.draft?
|
||||
halt(404, json("error" => "not_found")) if post.nil?
|
||||
halt(404, json("error" => "draft")) if post.draft?
|
||||
|
||||
json(post.detail)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user