Home > other >  Why I don't have to specify verbs() for "GET" for my custom REST action?
Why I don't have to specify verbs() for "GET" for my custom REST action?

Time:06-14

I have created a standard enter image description here

enter image description here

What am I missing? Why I don't need to specify this new action / router in verbs() for GET (I figured out that I must do this for other verbs)?

CodePudding user response:

In the referenced question/answer you were working with existing action index that already had rule for yii\filters\VerbFilter to only allow GET or HEAD verbs for that action.

But in case of completely new action test there is no existing rule for VerbFilter. If there is no rule for action the VerbFilter will allow any request. That's why if you don't specify rule for test action any verb set up in router will work. Once you specify the rule for test in verbs() method, only allowed verbs will make it through VerbFilter.

  • Related