Closed cowmanjoe closed 5 years ago
What should the body of the request look like? I tried {"email": "abc@gmail.com"}
but it didn't work.
No body for the request. For this one I just included it in the URL so the request would look like http://localhost:5000/mailing_list?email=abc@gmail.com
Could you add email validation in this PR too? It can just be a regex check.
I think POST makes sense here, POST is for creation and PUT is used for both creation and updates. There aren't really updates happening for this endpoint.
@frostyshadows True, that would be easy to implement. I'll return a 400 if it's an invalid email address. For deletion though, I won't add validation so we can use the API to delete invalid emails if they somehow get in there.
This is a pretty simple PR. Added a new entity i.e. table to the database that has 'email' as the only column. It is also the primary column, so duplicates are automatically avoided this way. There isn't yet validation on the emails of any kind so any string can be put in there.
One question: should the verb for adding a new email be a POST or a PUT? I wasn't sure about that, but if you guys have an opinion about that let me know.