nitc :: APIHandler :: mentity_from_uri
/:id
.Send 400 if :id
is null.
Send 404 if no entity is found.
Return null in both cases.
# Try to load the mentity from uri with `/:id`.
#
# Send 400 if `:id` is null.
# Send 404 if no entity is found.
# Return null in both cases.
fun mentity_from_uri(req: HttpRequest, res: HttpResponse): nullable MEntity do
var id = req.param("id")
if id == null then
res.api_error(400, "Expected mentity full name")
return null
end
var mentity = find_mentity(id)
if mentity == null then
res.api_error(404, "MEntity `{id}` not found")
end
return mentity
end
src/doc/api/api_base.nit:68,2--84,4