Expected behavior:
Posting to a recently deleted topicid should result in a 404 or other error, indicating that the resource doesn't exist.
Attempting to GET a non-existent topicid will also return 404 Not Found or (per previous spec) create a new topic and return 201 Created same as POST /topic/
Current behavior:
Posting to an unused topic does nothing but raises no error, because
UPDATE topics SET content = $2 WHERE id = $1
does nothing when there are no rows with the queried id. The request then returns 200 OK, indicating that it successfully updated a topic when none exists.
Attempting to GET the same topic will return another 200 OK after actually creating an entry for that topic, and will return a body with only {status: 'success'} and no topic field.
Now that new topics are created with POST /topic/ I think it would make sense to remove the GET /topic/:id option, both for redundancy/confusion and for better https semantics.
PR with integration tests/reproducing examples for the above forthcoming
Expected behavior: Posting to a recently deleted
topicid
should result in a 404 or other error, indicating that the resource doesn't exist.Attempting to
GET
a non-existenttopicid
will also return404 Not Found
or (per previous spec) create a new topic and return201 Created
same asPOST /topic/
Current behavior: Posting to an unused topic does nothing but raises no error, because
does nothing when there are no rows with the queried
id
. The request then returns200 OK
, indicating that it successfully updated a topic when none exists.Attempting to
GET
the same topic will return another200 OK
after actually creating an entry for that topic, and will return a body with only{status: 'success'}
and no topic field.Now that new topics are created with
POST /topic/
I think it would make sense to remove theGET /topic/:id
option, both for redundancy/confusion and for better https semantics.PR with integration tests/reproducing examples for the above forthcoming