The restful service by default returns xml, json and html. When setting the format param in the url to return xml and json they work fine however, when setting it to html it throws an error similar to …response can’t be an array.
I have manged to get it to work by doing something like the following in my Rest controller
public function actions() {
$formatParam = $this->behaviors()['contentNegotiator']['formatParam'];
if (\Yii::$app->request->get($formatParam) == 'html') {
//don't return default actions use defined ones below
return;
}
return parent::actions();
}
public function actionIndex() {
return $this->render('index');
}
It would be nice if i could just set html and it would call whatever action instead of the default one. My question is what is the best way to support html while still keeping the other formats listed above?