5

what's the correct http verb for a request that simply make the server send an email without altering the status of the whole webapp?

I am working on a Rails project and I need to define the route someway:

Rails.application.routes.draw do

  get 'self_emailer/email_me'
  ...

end
masciugo
  • 1,113
  • 11
  • 19
  • This question highlights the inadequacies of REST conventions. If you are performing an action that doesn't alter the state of the app and isn't for the purpose of fetching data to the client then there is no verb in REST that accomodates. They should add a SEND verb into HTTP – Toby 1 Kenobi Dec 01 '20 at 02:45

1 Answers1

5

You can use POST, as a new email resource will effectively be created and delivered. I would definitely not use GET, as the user may easily reload the browser or access the page by mistake, with the risk of delivering tons of emails.

Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
  • 2
    But when you send an email you don't create a new resource in your db, however you are right about the user reloading the browser and sending more emails (if your backend doesn't take care of that) – Gilbert R. Jul 16 '19 at 16:30