Is it safe to not implement HttpPostActionInterface

magento2

Is it safe to not implement HttpPostActionInterface ?

From:

class NewAction extends SubscriberController implements HttpPostActionInterface

To:

class NewAction extends SubscriberController

My goal on removing the implement HttpPostActionInterface was to prevent the page on displaying the 404 page if no post was sent. Our requirement was only to display a blank page when user manually load the link.

Or if you have other option on displaying blank page instead displaying 404 not found content.

Other Classes connected/extended that might help:

SubscriberController

abstract class Subscriber extends \Magento\Framework\App\Action\Action

\Magento\Framework\App\Action\Action

abstract class Action extends AbstractAction

AbstractAction

abstract class AbstractAction implements \Magento\Framework\App\ActionInterface

Best Answer

Your Controller Must Implement POST or GET Action Interface Class Other wise it will give you 404 No Found to your request

if your controller SubscriberController is implement any of ActionInterface its okay you don't need to implement that again

Update

The Class \Magento\Framework\App\Action\Action can be used but it is depreciated after Magneto 2.4 so it's a good practice to implement PostActionInterface

Related Topic