pdx-cs-rust-web / knock-knock

class webserver demo spring 2024
Other
2 stars 3 forks source link

#6: Added PUT method to /joke/:id endpoint #7

Closed relia1 closed 6 months ago

relia1 commented 6 months ago

Description:

This PR add a PUT method and some additional minor tweaks to the joke API

  1. Add PUT method to update jokes: A new endpoint has been added at /joke/:id to accept PUT requests, allowing users to update joke content. The happy path is the user updates an existing joke.
  2. This endpoint can return 200, 400, 404, and 422.
  3. There is some minimal validation to make sure that the payload doesn't have an empty id string. If it does we return a 422.
  4. Updated POST of a new joke to return a 201 (CREATED) on success

Checklist

BartMassey commented 6 months ago

Not sure whether this should provide an alternate way to add a new joke? I can see both sides of this one. Thoughts?

relia1 commented 6 months ago

After reading this https://www.rfc-editor.org/rfc/rfc9110#PUT I am actually leaning towards having the PUT return 404 there instead.

relia1 commented 6 months ago

201 for the PUT has been updated to 404. I did keep the 201 for the POST, I can remove that if wanted.

BartMassey commented 6 months ago

The 201 for POST is a fine idea and I meant to do it earlier.

BartMassey commented 6 months ago

Thanks much!